首页 > 文章列表 > python中的def语句是什么意思

python中的def语句是什么意思

Python 函数定义
379 2022-08-07

python中的def语句是define的意思,用来定义函数。用法为:“def 函数名(参数1, 参数2, ……, 参数N): 执行语句”。

def是define的意思,用来定义函数。



如:



def 函数名(参数1, 参数2, ……, 参数N): 执行语句



# 例:简单的函数使用

# 定义函数
def hello():
    print 'hello python!'
     
# 调用函数       
hello()