我在python 2.7中使用raw_input API
我做:
mass_storage_choice = raw_input("Have you enabled USB mass storage on the phone Yes or No?");
我明白了:
Traceback (most recent call last):
File "C:\tools\ide\juno\eclipse\plugins\org.python.pydev_2.7.3.2013031601\pysrc\pydevd_comm.py", line 765, in doIt
result = pydevd_vars.evaluateExpression(self.thread_id, self.frame_id, self.expression, self.doExec)
File "C:\tools\ide\juno\eclipse\plugins\org.python.pydev_2.7.3.2013031601\pysrc\pydevd_vars.py", line 376, in evaluateExpression
result = eval(compiled, updated_globals, frame.f_locals)
File "<string>", line 1, in <module>
NameError: name 'Y' is not defined
任何想法为什么?
答案 0 :(得分:0)
如果您在代码中使用了if ... then循环,请确保您实际上将Y放在单引号中。就像这样&#39; Y&#39;。因为我感觉你正在处理根据我的Y输入,表示是。如果我错了,请更正我。
答案 1 :(得分:0)
从用户那里获得输入后,将输入传递给要定义的应该起作用的变量。