Python 是一种选择性解释语言吗?为什么下面的代码不起作用?

问题描述 投票:0回答:1

程序是从上到下运行的,为什么下面的代码不执行块中的第一行就直接抛出错误?

if 5 > 2:
 print("Two is less than Five!")
        print("Five is greater than two!")

错误: 文件“/Users/____/Desktop/Python practise/practise.py”,第 3 行 print("五比二大!") 缩进错误:意外缩进

python python-3.x compiler-errors indentation interpreted-language
1个回答
0
投票

您不需要在第三行中进行额外的缩进。这是带有正确列表的代码:

if 5 > 2:
    print("Two is less than Five!")
    print("Five is greater than two!")
© www.soinside.com 2019 - 2024. All rights reserved.