python中的def语句是什么意思

Python (666) 2023-06-03 16:06:10

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

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

如:

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

# 例:简单的函数使用

#定义函数
defhello():
print'hellopython!'

#调用函数
hello()

推荐课程:Python基础视频教程(前端基础)

THE END

发表回复