美文网首页
Python基础错误1

Python基础错误1

作者: goodAndBad | 来源:发表于2017-11-07 10:54 被阅读0次

函数默认参数

Error : non-default argument follows default argument

def sde(a='heihei',b):
    print(a,b);

sde(b=1);

默认参数要在后边,否则会报错。

正确代码:

def sde(b,a='heihei'):
    print(a,b);

sde(b=1);

运行结果:

heihei 1

相关文章

网友评论

      本文标题:Python基础错误1

      本文链接:https://www.haomeiwen.com/subject/whbdmxtx.html