暂停Python程序的正确方法

2024-05-14 20:36:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在用输入函数来暂停我的脚本

print("something")
wait = input("PRESS ENTER TO CONTINUE.")
print("something")

有没有正式的方法来做这个?


Tags: to方法函数脚本inputsomethingpressprint
3条回答

仅适用于windows使用:

import os
os.system("pause")

我想你想在没有输入的情况下暂停

使用

time.sleep(secs)

对我来说似乎很好(或者在Python 2.X中是raw_input())。或者,如果您想暂停一定的秒数,可以使用time.sleep()

import time
print("something")
time.sleep(5.5)    # pause 5.5 seconds
print("something")

相关问题 更多 >

    热门问题