函数可以返回任何值,包括列表和字典等较复杂的数据结构。
示例:
def say_hello(first_name, last_name):
"""返回一个人的字典"""
person = {"first_name": first_name, "last_name": last_name}
return person
person = say_hello("Li", "Can")
print(person)
运行输出:
函数可以返回任何值,包括列表和字典等较复杂的数据结构。
示例:
def say_hello(first_name, last_name):
"""返回一个人的字典"""
person = {"first_name": first_name, "last_name": last_name}
return person
person = say_hello("Li", "Can")
print(person)
运行输出: