如何使Python命令提示符不可点击?

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

我在Windows 10中使用Python 3.7作为开发环境。我写了一个连续时间应用程序,我在命令提示符上运行我的python脚本:

cmd: runpythonscript.py 

但是,如果将鼠标放在命令提示符上并单击它,命令提示符将暂停代码。除非它已关闭,否则我不希望从命令提示符进行任何外部中断。

有没有办法做到这一点?

这里有一个可以尝试的简单实时代码:

import time

def main():
    is_running = True
    time_slept = 0
    while is_running:
        time.sleep(1)
        print("I slept " + str(time_slept) +" seconds")
        time_slept += 1

if __name__ == '__main__':
    main()
python windows windows-10 command command-prompt
1个回答
1
投票

这实际上是Linux上大多数终端的默认行为。如果进入复印模式,则暂停该过程。你可以删除quick edit mode以达到你想要的行为:enter image description here enter image description here

对不起德国标签,如果你想改变语言,窗户真的很恶心。东西应该放在同一个地方。

© www.soinside.com 2019 - 2024. All rights reserved.