python中报错non-default argument follows default argument
原因是我把带有默认值的参数放在了不带默认值的参数前面
def person_name (first_name,mid_name='',last_name):
"""字典"""
if mid_name:
full_name = f"{first_name} {mid_name} {last_name}"
else:
full_name = f"{first_name} {last_name}"
return full_name.title()
第一排中的“mid_name=’’ ”,含有默认值。
改一下就好了
def person_name (first_name,last_name,mid_name=''):
"""字典"""
if mid_name:
full_name = f"{first_name} {mid_name} {last_name}"
else:
full_name = f"{first_name} {last_name}"
return full_name.title()