Python语法错误,错误为“

2024-03-29 13:52:32 发布

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

您好,我是一个noob,刚开始使用python,所以我想用raw_input玩得开心,添加一些随机的问题和东西,但是我遇到了一个错误。它说无效的语法是”。我一直试图把它放在不同的地方,但没有成功我很抱歉,如果这是一个非常愚蠢的问题,但有人能帮我出来。你知道吗

这里有一行错误

print " Oh okay then %s . You came from %s , right? Oh i see you came here to %s" % (name,so,fun)

它指向%s旁边的结束语

我在用atom

编辑:这里是错误

 File "C:\Users\USER\AppData\Local\atom\app-1.26.1\Testing.py", line 10
print " Oh okay then %s . You came from %s , right? Oh i see you came here %s. " % (name, so, fun)
                                                                               ^

SyntaxError: invalid syntax

完整代码如下:

name = raw_input("Hello whats your name?")
so = raw_input("From where did you come from")
fun = raw_input("Interesting, why did you come here?")
#start the sentence with "for"


print " Oh okay then %s . You came from %s , right? Oh i see you came here %s. " % (name, so, fun)

如果我不能用raw_input,那我能用什么呢?我学会了用它。你知道吗


Tags: namefromyouinputrawsohere错误
1条回答
网友
1楼 · 发布于 2024-03-29 13:52:32

我通过在整件事上加括号来解决这个问题,比如

print (" Oh okay then %s . You came from %s , right? Oh i see you came here to %s" % (name,so,fun))

我还认为原始的输入被替换为'input()'。你知道吗

相关问题 更多 >