黑马博学谷python+大数据2022开发
创建函数
在 Python 中,使用 def
关键字定义函数:
实例
def my_function(): print("Hello from a function")
调用函数
如需调用函数,请使用函数名称后跟括号:
实例
def my_function(): print("Hello from a function") my_function()
def my_function(fname): print(fname + " Gates") my_function("Bill") my_function("Steve") my_function("Elon")