2
파이썬 대화 형 모드에서 벨소리처럼 코딩하는 동안 구문 오류 반응이 나타납니다.python 대화식 모드의 버그?
>>> while True:
... reply = raw_input('enter text:')
... if reply == 'stop':
... break
... print reply
... print 'bye'
File "<stdin>", line 6
print reply
^
SyntaxError: invalid syntax
>>>
그러나 스크립트로 저장하면 정상적으로 실행됩니다.
~ $cat test.py
#!/usr/bin/env python
# encoding=utf8
while True:
reply = raw_input('enter text:')
if reply == 'stop':
break
print reply
print 'bye'
~ $python test.py
enter text:19
19
enter text:456789
456789
enter text:$%^&*(
$%^&*(
enter text:TGHJKLO:P
TGHJKLO:P
enter text:#$%^&*()_
#$%^&*()_
enter text:stop
bye
버그입니까? 또는 파이썬 대화 형 모드에 대해 알아야 할 다른 것들? 당신이이 비어 있어야합니다 들여 쓰기의 첫 번째 열에로 돌아 가면
~ $python -V
Python 2.6.6
가능한 중복 (http://stackoverflow.com/questions/5751135/python-print-done-after-while)이 –