39 函数返回值

函数可返回任何类型的值。

  1. 返回简单值

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")
  1. 返回字典

# 函数返回字典
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'}

你可能感兴趣的:(python,servlet,服务器,java,python)