wgz890813 发表于 2018-1-28 15:11:57

函数

0        创建函数:def 变量名() ()是必不可少的
>>> def name():
        print('555')
>>> name() #调用函数,当python调用的时候是往上寻找
555
1        函数的返回值return
>>> def voice(V1, V2):
        V = V1 + V2
        print(V)
>>> voice(1,2)
3
可以变为:
>>> def voice(V1, V2):
        return (V1 + V2)
>>> voice(4,5)
9
页: [1]
查看完整版本: 函数