我在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()