【问题标题】:SyntaxError: multiple statements found while compiling a single statement [Real Python Rookie] [duplicate]SyntaxError:编译单个语句时发现多个语句 [Real Python Rookie] [重复]
【发布时间】:2018-09-06 13:54:06
【问题描述】:
i=9
while i>0:
    for j in range(1,i+1):
        print(str(i)+"*"+str(j)+"="+str(i*j),end=" ")
    print("\n")
    i--

SyntaxError: 在编译单个语句时发现多个语句 [Real Python Rookie]

【问题讨论】:

  • i-- 不是您在 Python 中使用的,Python 没有 -- 运算符。你会改用i -= 1。但是,该行本身不会抛出具有完全相同消息的异常。
  • 您显示的错误实际上从未由 Python 本身发出。您正在使用什么程序会引发该错误?您是否尝试让 shell 解析这个(因为您使用 shell 作为标签)?
  • 啊,您将多行直接粘贴到 IDLE 控制台中。不要那样做。将其放入文件,然后运行该文件。
  • 哦,我看到一个小时前刚刚开始 python 非常感谢你

标签: python shell


【解决方案1】:

i-- 在 python 中不起作用。 -- 没有现有的运营商。例如,您可以使用 i -= 1 。

【讨论】:

    猜你喜欢
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    相关资源
    最近更新 更多