【问题标题】:This simple If statement send me an SyntaxError: invalid syntax on Python 3.6这个简单的 If 语句向我发送了 SyntaxError: invalid syntax on Python 3.6
【发布时间】:2020-01-17 17:13:50
【问题描述】:
elephant_weight = 3000
ant_weight = 0.1

If elephant_weight > ant_weight:
 square()

我得到的错误是:

 File "c:/Users/AIRWEBDEV/Documents/exercice.py", line 37
    If elephant_weight > ant_weight:
                     ^
SyntaxError: invalid syntax

【问题讨论】:

  • Python 区分大小写。使用if 而不是If
  • 以下行中的缩进量看起来也不合适

标签: python python-3.x if-statement error-handling


【解决方案1】:

正确的语法是(注意小写的if):

if elephant_weight > ant_weight:
    square()

【讨论】:

    猜你喜欢
    • 2021-09-06
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-12
    • 1970-01-01
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    相关资源
    最近更新 更多