初学编程,学习python遇到个问题,求大神解答。 10
按照一个课后习题的要求做了这样一个的程序importeasyguicode="12345"guess=0tries=0whileguess!=codeandtries<5...
按照一个课后习题的要求做了这样一个的程序
import easygui
code="12345"
guess=0
tries=0
while guess !=code and tries<5:
guess=easygui.enterbox("please enter the password.")
if not guess:break
if guess!=code:
easygui.msgbox("password wrong")
tries=tries+1
if guess == code:
easygui.msgbox("you're in")
a=float(easygui.enterbox("what's the size of your tank?"))
b=easygui.enterbox("percent full?")
c=easygui.enterbox("km per liter?")
d=(a-5)*float(b)/100*float(c)
e=easygui.enterbox("how far is the next gasstasion?")
f="size of tank: "+str(a)+"\n"+"percent full: "+b+"\n"+"km per liter: "+c+"\n"+"you can go anoter " +str(d)+" km"+"\n"+"the next gas station is "+e+" km"+"\n"+"you can wait for the next station."
g="size of tank: "+str(a)+"\n"+"percent full: "+b+"\n"+"km per liter: "+c+"\n"+"you can go anoter " +str(d)+" km"+"\n"+"the next gas station is "+e+" km"+"\n"+"get gas now ."
if d>=float(e):
easygui.msgbox(f)
else:
easygui.msgbox(g)
else:
easygui.msgbox("out of try")
开始试的时候运行顺利,但是保存退出,重新打开后运行错误,显示:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python36\4.py", line 1, in <module>
import easygui
File "C:\Users\hp\AppData\Local\Programs\Python\Python36\lib\easygui.py", line 50
print "\n" * 3
^
SyntaxError: Missing parentheses in call to 'print'
>>>
而我新建个文档,把代码复制过去又能用了,请问这到底是怎么回事?
我刚发现只要用了easygui的程序,保存后第二次打开都不能用了
像这样的
import easygui
easygui.msgbox("aaa")
都是当时能用,重开就用不了了,请问是我哪里弄错了什么吗? 展开
import easygui
code="12345"
guess=0
tries=0
while guess !=code and tries<5:
guess=easygui.enterbox("please enter the password.")
if not guess:break
if guess!=code:
easygui.msgbox("password wrong")
tries=tries+1
if guess == code:
easygui.msgbox("you're in")
a=float(easygui.enterbox("what's the size of your tank?"))
b=easygui.enterbox("percent full?")
c=easygui.enterbox("km per liter?")
d=(a-5)*float(b)/100*float(c)
e=easygui.enterbox("how far is the next gasstasion?")
f="size of tank: "+str(a)+"\n"+"percent full: "+b+"\n"+"km per liter: "+c+"\n"+"you can go anoter " +str(d)+" km"+"\n"+"the next gas station is "+e+" km"+"\n"+"you can wait for the next station."
g="size of tank: "+str(a)+"\n"+"percent full: "+b+"\n"+"km per liter: "+c+"\n"+"you can go anoter " +str(d)+" km"+"\n"+"the next gas station is "+e+" km"+"\n"+"get gas now ."
if d>=float(e):
easygui.msgbox(f)
else:
easygui.msgbox(g)
else:
easygui.msgbox("out of try")
开始试的时候运行顺利,但是保存退出,重新打开后运行错误,显示:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python36\4.py", line 1, in <module>
import easygui
File "C:\Users\hp\AppData\Local\Programs\Python\Python36\lib\easygui.py", line 50
print "\n" * 3
^
SyntaxError: Missing parentheses in call to 'print'
>>>
而我新建个文档,把代码复制过去又能用了,请问这到底是怎么回事?
我刚发现只要用了easygui的程序,保存后第二次打开都不能用了
像这样的
import easygui
easygui.msgbox("aaa")
都是当时能用,重开就用不了了,请问是我哪里弄错了什么吗? 展开
2017-04-12
展开全部
猜测是因为print的时候没有加括号,因为python3.+的版本print的时候都要加括号,Python\Python36\lib\easygui.py目录下第50行。
追问
不是的,我在练习easygui,所以没用print,而且刚开始运行成功过,就是保存后关掉再打开就不行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询