Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7原始输入脚本_Python_Python 2.7 - Fatal编程技术网

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")