本文介绍了“解析时出现意外的 EOF"在“尝试"之后陈述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我真的,真的是 Python 新手,正在制作一个小型测试程序.
I'm really, really new to Python and was making a small test program.
这是我的代码:
def start ():
print ("This is where text would be")
prompt_sta ()
def prompt_sta ():
prompt_0=raw_input("Input a Command: ")
try:
if prompt_0 == 'Okay':
next_screen ()
else:
print ('Type Okay.')
prompt_sta ()
当我尝试运行它时,我收到解析时意外的 EOF"错误.
when I try to run it I get the "Unexpected EOF while parsing" error.
推荐答案
对于 EOF 错误,你可以摆脱那个 try: like so
For the EOF error, you can just get rid of that try: like so
def start ():
print ("This is where text would be")
prompt_sta ()
def prompt_sta ():
prompt_0=raw_input("Input a Command: ")
if prompt_0 == 'Okay':
next_screen ()
else:
print ('Type Okay.')
prompt_sta()
你也可以只添加一个except子句,正如费尔南多所说,如果你仍然想使用try:
You can also just add an except clause, as Fernando said, if you still want to use try:
这篇关于“解析时出现意外的 EOF"在“尝试"之后陈述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!