简体   繁体   English

python:如果在交互模式下阻塞,如何退出

[英]python:how to exit if block during interactive mode

just play with Python, a small question on interactive mode. 只是玩Python,这是交互式模式的一个小问题。

steps: 脚步:

  1. enter python interactive mode, following line shows detail on interactive mode List item 进入python交互模式,以下行显示了交互模式的详细信息列表项
  2. >>>flag=True >>> flag =真
  3. >>>if flag: >>>如果标记:
  4. . . . print("flag is True") 打印(“标志为真”)
  5. after above step, i WANT to exit the whole if block. 经过上述步骤后,我想退出整个if块。 but if press enter for above line 4, it will start line with "...", which means still in if block. 但如果在第4行上方按Enter键,它将以“ ...”开始,这表示如果仍在块中。

question: HOW CAN I exit if block and write sth like the following in interactive mode : 问题:如果在交互模式下进行如下阻止和写操作,我如何退出:

flag=True
if flag:
    print("flag is True")
print("exit if now ")

在交互式模式下,按两次Enter将退出if块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM