def info(address,born,name =‘imooc’):
print(’{}-{}出生于{}’.format(name,address,born))
info(‘程序员的梦工厂’,‘2013年8月’)
研究了半天发现
如果把name = 'imooc’默认参数放在前面会报错:non-default argument follows default argumen
不含默认参数不能放在含默认参数的后面,如果放了,后面的不含默认参数的必须用关键字传参,加*
如果在下面输入info(address=‘程序员的梦工厂’,‘2013年8月’)会报错positional argument follows keyword argument
关键字参数必须放在位置参数后面
positional argument follows keyword argument和non-default argument follows default argument解决办法
最新推荐文章于 2022-09-24 18:24:24 发布