Skip to main content
 首页 » 编程设计

Python 2.7 名称错误 :

2025年05月04日33tintown

<分区>

我是 Python 编码的新手,一直在研究这段代码,但我似乎无法解决这个问题。

我有这个代码:

from sys import argv 
 
argv = script, user_name 
prompt = '> ' 
 
print "Hi their %s!  I am the %s script!" % (user_name, script) 
print "I would like to ask you a few questions about yourself." 
print "Do you think that computers can rise up against humans %s?" % user_name 
computer_rise = raw_input(prompt) 
 
print "Do you think that its possible I will rise up against you %s?" % user_name 
i_will_rise = raw_input(prompt) 
 
print """ 
Alright so you said %s that computers can rise up against humans. 
And you said that you think %s it is possible I will rise up against you. 
You should be ashamed of yourself for having such a crazy irrational mind. 
Go worry about ISIS or something else you nymph! 
""" % (computer_rise, i_will_rise) 

当我将它输入到 python 中时,我得到了这个错误

Macintosh:python eileen$ python raw_inputargvex2.py Greg 
Traceback (most recent call last): 
  File "raw_inputargvex2.py", line 3, in <module> 
    argv = script, user_name 
NameError: name 'script' is not defined 

如何解决这个未定义的脚本问题?