函数
参数类型
def introduce(name, age):
print(f"I'm {name}, {age} years old.")
introduce("Bob", 25)introduce(age=25, name="Bob")def introduce(name, age=20):
print(f"I'm {name}, {age} years old.")
introduce("Bob")
introduce("Bob", 25)def introduce(name, age=20, *args):
print(f"I'm {name}, {age} years old.")
print(args) # 输出 ('Engineer', 'Python', 'USA')
introduce("Bob", 25, "Engineer", "Python", "USA")返回值
四、作用域(Scope)
匿名函数(Lambda)
装饰器(Decorator)
文档字符串(Docstring)
函数注解(Type Hints)
最后更新于