python 按任意键退出

python实现按任意键退出

在excel调用python脚本时,想看一下执行的log,就不希望执行完后里面退出

import msvcrt 

print("Press any Key to Exit.")
msvcrt.getch()

当然也可以实现按特定键后退出

import msvcrt

print("Press 'D' to exit...")
while True:
    if ord(msvcrt.getch()) in [68, 100]:
    break
posted @ 2023-09-28 11:27  下夕阳  阅读(264)  评论(0编辑  收藏  举报