在学习关键字参数及默认值时,输入关键字和默认值如下:
def hello(greeting = 'hello', name)
print('{} {}'.format(greeting, name))
运行时报错
问题点:
当第一个关键字含有默认参数,其他关键字均应含有默认参数。所以将含有默认值参数的关键字后移即可解决问题:
def hello( name, greeting = 'hello')
print('{} {}'.format(greeting, name))
hello('wd')
===================== RESTART: E:/practice_py/20200229-1.py ====================
hello wd