# coding:utf-8'''
def get_format_name(fist_name,last_name,mide_name="",age =18):
#嗯,返回全部名字 #参数赋值是不需要留空格,形参实参都是。
if mide_name:
fallname = fist_name.title()+mide_name.title()+last_name.title()
else:
fallname = fist_name.title()+last_name.title()
file = {"姓名":fallname}
#还可以增加函数的实参
if age:
file["年龄"] = age
return fileprint(get_format_name("李","壮","大",30))
'''def build_profile(first,last,**user_info):
'''创建一个字典'''
dic = {}
dic["fist_name"] = first
dic["last_name"] = last
for key,value in user_info.items():
dic[key] = value
return dic
a = build_profile("张","三",年龄=30,身高=180)#a = build_profile("张","三","年龄"=30,"身高"=180)是会报错的,实参默认string这个需要注意一下
#a = build_profile("张","三",{"年龄":30,"身高":180})也会报错,看来不是字典啊print(a)
def get_format_name(fist_name,last_name,mide_name="",age =18):
#嗯,返回全部名字 #参数赋值是不需要留空格,形参实参都是。
if mide_name:
fallname = fist_name.title()+mide_name.title()+last_name.title()
else:
fallname = fist_name.title()+last_name.title()
file = {"姓名":fallname}
#还可以增加函数的实参
if age:
file["年龄"] = age
return fileprint(get_format_name("李","壮","大",30))
'''def build_profile(first,last,**user_info):
'''创建一个字典'''
dic = {}
dic["fist_name"] = first
dic["last_name"] = last
for key,value in user_info.items():
dic[key] = value
return dic
a = build_profile("张","三",年龄=30,身高=180)#a = build_profile("张","三","年龄"=30,"身高"=180)是会报错的,实参默认string这个需要注意一下
#a = build_profile("张","三",{"年龄":30,"身高":180})也会报错,看来不是字典啊print(a)