1.定义函数封装:
def 函数名():
函数中的代码
函数中的代码
def这行代码最后需要冒号
2.存在冒号就需要换行缩进
3.处于def 缩进中的代码,称为函数体
举例:
def say_hello():
print("hello")
print('hi')
print('你好!')
say_hello()
2.函数调用:函数调用,就是使用函数名字去执行函数中的代码
函数名字()下面有
3.局部变量和全局变量:如下图
微信扫一扫
1.定义函数封装:
def 函数名():
函数中的代码
函数中的代码
def这行代码最后需要冒号
2.存在冒号就需要换行缩进
3.处于def 缩进中的代码,称为函数体
举例:
def say_hello():
print("hello")
print('hi')
print('你好!')
say_hello()
2.函数调用:函数调用,就是使用函数名字去执行函数中的代码
函数名字()下面有
3.局部变量和全局变量:如下图
相关推荐