0
일련의 튜토리얼을보고 파이썬 3을 배우고 있습니다.
옵션 기능 인수 (*args
)에 대한 이러한 비디오 중 하나에서 강사는 for 루프를 사용합니다 함수 (튜플)에 전달 된 선택적 매개 변수를 인쇄합니다.파이썬 3 - 인쇄 오류 * for 루프를 사용한 args
강사 스크립트 :
def test(a,b,c,*args):
print (a,b,c)
for n in args:
print(n, end=' ')
test('aa','bb','cc',1,2,3,4)
출력 :
C:\Python33\python.exe C:/untitled/0506.py
Traceback (most recent call last):
File "C:/untitled/0506.py", line 4, in <module>
for n in args: print(n, end=' ')
NameError: name 'args' is not defined
Process finished with exit code 1
def test(a,b,c,*args):
print (a,b,c)
print (args)
test('aa','bb','cc',1,2,3,4)
내가 강사의 스크립트를 실행하려고하면
는 오류가 발생합니다
출력 :
aa bb cc
(1, 2, 3, 4)
Process finished with exit code 0
은 무엇 오류의 원인?
P.S : Python 3.3.0을 사용하고 있습니다.
OMG! 얼마나 어리석은 지! 마틴 감사합니다. –