0
在我的設置腳本中,我用了一年的函數現在突然中斷。我剪切並粘貼成IPython的,看它是否是文件,但我得到的一般語法錯誤這裏不僅是沒有錯誤可見的,但用於工作中的作用並沒有改變SyntaxError:從正在工作的函數中解析出意外的EOF
In [8]: def gather(msg=None, default=None):
...: while True:
...: text = msg + '\n'
...: if default:
...: text += "the default is {default}...press enter to accept\n".format(default=default)
...: answer = input(text)
...: return answer or default
...: answer = input(text)
...: if not answer:
...: continue
...: return answer
...:
In [9]: EMAIL = gather(msg='What is your work email?', default='[email protected]')
What is your work email?
the default is [email protected] enter to accept
File "<string>", line unknown
^
SyntaxError: unexpected EOF while parsing
這裏是func
def gather(msg=None, default=None):
while True:
text = msg + '\n'
if default:
text += "the default is {default}...press enter to accept\n".format(default=default)
answer = input(text)
return answer or default
answer = input(text)
if not answer:
continue
return answer
我在使用python 2,和以前一樣。爲什麼這會打破?謝謝
的可能的複製[Python的意外EOF而解析](http://stackoverflow.com/questions/5074225 /蟒-意想不到-EOF·維持同時解析) –