【问题标题】:Enter compound statements interactivly以交互方式输入复合语句
【发布时间】:2011-03-26 21:31:27
【问题描述】:

我在 IDLE 提示符下运行这个简单语句时遇到问题。

if True:
    print("True") # need to press ENTER twice?
else:
  print("False")  # need to press ENTER twice?

感谢任何帮助。

【问题讨论】:

  • 使用 Python 2 还是 3? 2 看起来不错;需要在 3 中使用print()
  • 哦,你的缩进不一致。
  • 是 Python3。固定并重新标记。

标签: python python-3.x


【解决方案1】:

当你按下回车键时,IDLE 会自动缩进。按删除删除自动缩进。

if True:
    print("True") # press return, then backspace
else:
    print("False")

【讨论】:

  • 工作就像一个魅力。非常感谢。必须等待 5 分钟才能接受,因为我的配额已用完,所以无法投票:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多