所以,我正在使用Pydev版本7.2.1.201904261721的Eclipse Oxygen.3a版本(4.7.3a,20180405-1200)。我正在通过pdf学习python,并且在重新启动后,我的代码被“未定义的变量:打印”垃圾邮件淹没。但是,当我解释并运行代码时,一切正常。为什么会这样?我该如何解决? 这是我的代码(在单个项目中标题为rock1.py):
'''
Created on Jan 29, 2019
@author: Aaron
'''
import random
choices= ["rock paper sissers "]
player=input("do you want to be rock paper or sissors (or quit?)")
computer= random.choice("choices")
while player!=("quit"):
print("you choose,"+player+",computers choose"+computer+".")
if player== computer:
print("it's a tie")
else:
print("computer wins")
if player == ("rock"):
if computer == ("sissors"):
print("youwin")
elif player == ("sissors"):
if computer==("paper" ):
print("you win")
elif player==("paper"):
if computer== ("rock"):
print("youwin")
else:
print("computer win")
else:
print ("i think there is a kind of error")
print("i think there is a kind of error")
错误(直接从“ Eclipse问题”标签中获取):
Description Resource Path Location Type
Undefined variable: input rock1.py /rock sissers paper line 7 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 10 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 12 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 14 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 17 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 20 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 23 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 25 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 27 PyDev Problem
Undefined variable: print rock1.py /rock sissers paper line 28 PyDev Problem
答案 0 :(得分:0)
通常,当PyDev无法与其为获取内置令牌而产生的外壳进行通信时就会发生这种情况(Python 3上的print
就是这种情况)。
请查看http://www.pydev.org/faq.html#HowToFixCodeCompletion以查看它是否有助于解决您的问题...您可能还想检查一下解释器的配置是否正确,或者错误日志中是否有错误-请参阅:http://www.pydev.org/faq.html#HowdoIReportaBUG,以获取有关错误日志的详细信息。