Python 2.7原始输入脚本

2024-06-14 21:54:35 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我尝试编写一个代码,在您使用raw_input在输出中键入Goku之后,它将打印Hello Goku。当我输入Goku时,它什么也不做(在Python空闲GUI中)。 但在Python命令行中

File "<stdin>", line 1
     print ("hello Goku")
     ^
IndentationError: unexpected indent

这是我的剧本:

x = raw_input('What is your name?')
if raw_input() == "Goku":
    print ("hello Goku")

Tags: 代码命令行helloinputraw键入stdinline