-1
코드는 파이썬 2.5에서 실행되지만이 예외는 2.6에서 실패합니다.파이썬 2.6에서 "키워드 인수 반복"예외를 취소 할 수 있습니까?
코드는 파이썬 2.5에서 실행되지만이 예외는 2.6에서 실패합니다.파이썬 2.6에서 "키워드 인수 반복"예외를 취소 할 수 있습니까?
예외는 소스의 구문 오류이며이를 수정하는 유일한 방법은 함수 호출을 수정하는 것입니다.
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(x): pass
...
>>> f(x=1, x=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for keyword argument 'x'
>>> f(x=1, **{'x': 2})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for keyword argument 'x'
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(x): pass
...
>>> f(x=1, x=2)
File "<stdin>", line 1
SyntaxError: keyword argument repeated
>>> f(x=2, **{'x': 1})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for keyword argument 'x'
** what ** code? <><> – SilentGhost
파스 타임 오류라고 가정합니다. 이 일을하는 코드는 어쨌든 고장났습니다. – delnan