Python 2.7原始输入脚本
因此,我正在尝试制作一个代码,在您使用Python 2.7原始输入脚本,python,python-2.7,Python,Python 2.7,因此,我正在尝试制作一个代码,在您使用raw\u input在输出中键入小悟空后,它将打印Hello小悟空。当我输入Goku时,它什么也不做(在Python空闲GUI中)。 但是在Python命令行中,它的 File "<stdin>", line 1 print ("hello Goku") ^ IndentationError: unexpected indent 您需要比较if语句中的x 原始输入()将用户输入存储到变量x中。不必比较x和字符串“Goku”
raw\u input
在输出中键入小悟空后,它将打印Hello小悟空。当我输入Goku时,它什么也不做(在Python空闲GUI中)。
但是在Python命令行中,它的
File "<stdin>", line 1
print ("hello Goku")
^
IndentationError: unexpected indent
您需要比较if语句中的x
原始输入()将用户输入存储到变量x中。不必比较x和字符串“Goku”缩进错误表示缩进错误。从您发布的内容中我看不到缩进问题,但它必须存在于您的代码中。这与OP的问题无关,即缩进错误。这可能是对问题的评论,而不是回答。
x = raw_input('What is your name?')
if raw_input() == "Goku":
print ("hello Goku")