比思論壇

標題: Python 函数 [打印本頁]

作者: hncszz    時間: 2020-12-6 15:48
標題: Python 函数
函数是一种仅在调用时运行的代码块。
您可以将数据(称为参数)传递到函数中。
函数可以把数据作为结果返回。

创建函数在 Python 中,使用 def 关键字定义函数:
实例def my_function():  print("Hello from a function")
调用函数如需调用函数,请使用函数名称后跟括号:
实例def my_function():  print("Hello from a function")my_function()





歡迎光臨 比思論壇 (http://108.170.5.77/) Powered by Discuz! X2.5