函数可返回任何类型的值。
返回简单值
def get_full_name(first_name, last_name, middle_name=" "):
full_name = first_name + " " + middle_name + " " + last_name
return full_name
name = get_full_name("Tom", "Li")
返回字典
# 函数返回字典
def build_person(first_name, last_name):
person = {"first_name": first_name, "last_name": last_name}
return person
P = build_person("li", "tom")
print(P)---》{'first_name': 'li', 'last_name': 'tom'}