1
yemoluo Sep 27, 2018 因为 args 参数要求是一个元组。
Python 中的元组,如果只有一个元素,就需要在后面加逗号,否则会认为是小括号 ```python >>> d = (1) >>> d 1 >>> d = (1,) >>> d (1,) >>> def function(arg,*args,**kwargs): print(type(arg)) print(type(args)) print(type(kwargs)) >>> function(1) <class 'int'> <class 'tuple'> <class 'dict'> ``` |
2
dalang Sep 27, 2018 ```
>>> type( ('a') ) <type 'str'> >>> type( ('a',) ) <type 'tuple'> ``` |
3
silhouette Sep 27, 2018 via Android
这个就是 Python 单一元素元组必须要加逗号的问题啊
|