在学习关键字参数及默认值时,输入关键字和默认值如下:

    1. def hello(greeting = 'hello', name)
    2. print('{} {}'.format(greeting, name))

    运行时报错
    image.png
    问题点:
    当第一个关键字含有默认参数,其他关键字均应含有默认参数。所以将含有默认值参数的关键字后移即可解决问题:

    1. def hello( name, greeting = 'hello')
    2. print('{} {}'.format(greeting, name))
    3. hello('wd')
    4. ===================== RESTART: E:/practice_py/20200229-1.py ====================
    5. hello wd

    资料:
    SyntaxError错误