Python中用if……else语句编写代码,结果出现错误:
源码为:
<a href="https://www.gaodaima.com/tag/number" title="查看更多关于number的文章" target="_blank">number</a> = 2 if number == 2: print("you are fool") else: print("you are beautiful")
www#gaodaima.com来源gao!%daima.com搞$代*!码网搞代码
错误提示为:
仔细看了一下,结果是else的缩进发生了错误。
修正后的代码为:
number = 2 if number == 2: print("you are fool") else: print("you are beautiful")
运行结果为:
来源:搞代码网:原文地址:https://www.gaodaima.com