美文网首页
python学习笔记(12月11日)-python函数

python学习笔记(12月11日)-python函数

作者: pency | 来源:发表于2016-12-26 10:49 被阅读0次

python函数主要包括三个方面

1、系统库提供的内部函数

2、第三方提供的函数

3、自定义的函数


def定义一个函数

def we():

print('beautiful')

we()

返回

beautiful

>>>


def we(a,b):         #a和b为形参

return(a*b)

c= we(4,2)

print(c)

返回

8

>>>


def hh(a=1,b=3,c=5):

print('a is %d'%a)

print('b+c is %d'%(b+c))        %d表示整数

return (a,b+c)

d,e=hh(b=6,c=7)

print(d)

print(e)

返回

a is 1

b+c is 13

1

13

>>>

相关文章

网友评论

      本文标题:python学习笔记(12月11日)-python函数

      本文链接:https://www.haomeiwen.com/subject/aefpmttx.html