python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法,nonkeyword
python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法,nonkeyword
python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法
前言:
在Python中,这两个是python中的可变参数,*arg表示任意多个无名参数,类型为tuple,**kwargs表示关键字参数,为dict,使用时需将*arg放在**kwargs之前,否则会有“SyntaxError: non-keyword arg after keyword arg”的语法错误
def test(*arg,**kwargs): print arg print kwargs print "-------------------" if __name__=='__main__': test(1,2,3,4,5) test(a=1,b=2,c=3) test(1,2,3,a=1,b=3,c=5) output: (1, 2, 3, 4, 5) {} ------------------- () {'a': 1, 'c': 3, 'b': 2} ------------------- (1, 2, 3) {'a': 1, 'c': 5, 'b': 3} -------------------
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关内容
- 深入理解Python对Json的解析,深入理解pythonjson
- 关于Python面向对象编程的知识点总结,python面向对象编
- Python变量和数据类型详解,python变量数据类型
- Python错误提示:[Errno 24] Too many open files的分析与解决,
- 使用PyV8在Python爬虫中执行js代码,pyv8python
- python字符串中的单双引,python字符串单双引
- Python之日期与时间处理模块(date和datetime),pythondat
- 浅谈python中的实例方法、类方法和静态方法,浅谈pyt
- Python 遍历列表里面序号和值的方法(三种),python序号
- Python爬虫:通过关键字爬取百度图片,
评论关闭