语法错误:解析时意外的EOF [英] SyntaxError: unexpected EOF while parsing
本文介绍了语法错误:解析时意外的EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么这不工作请帮助
I have no idea why this does not work please help
import random
x = 0
z = input('?')
int(z)
def main():
while x < z:
n1 = random.randrange(1,3)
n2 = random.randrange(1,3)
t1 = n1+n2
print('{0}+{1}={2}'.format(n1,n2,t1)
当我运行它输出这个错误
When i run this it outputs this error
File "/Users/macbook/Documents/workspace/gamlir_filar/samlagning.py", line 12
^
SyntaxError: unexpected EOF while parsing
我正在使用eclipse和python 3.3,我不知道为什么会发生这种情况,有时会输出这样的错误。
I am using eclipse and python 3.3 and i have no idea why this happens. It sometimes outputs errors like this.
推荐答案
)
print()
:
print('{0}+{1}={2}'.format(n1,n2,t1))
,而且您还没有从 int()
存储返回的值,所以 z
仍然是一个字符串。
and you're also not storing the returned value from int()
, so z
is still a string.
z = input('?')
z = int(z)
或简单地:
z = int(input('?'))
这篇关于语法错误:解析时意外的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文