创新互联Python教程:怎么停止python脚本

铜鼓ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

1、time.sleep(secs)

参考文档原文:

Suspend execution for the given number of seconds. The argument may be a floating point number to 
indicate a more precise sleep time. The actual suspension time may be less than that requested because
any caught signal will terminate the sleep() following execution of that signal's catching routine. 
Also, the suspension time may be longer than requested by an arbitrary amount because of the 
scheduling of other activity in the system.

大意:

让程序执行暂停指定的秒数,参数可以是浮点型以指定精确的时间,但是程序真正暂停的时间可能长于请求的时间也可能短于暂停的时间。

2、raw_input( )

通过等待输入来让程序暂停。

3、os.system("pause")

通过执行操作系统的命令来让程序暂停,该函数是通过实现标准C函数system( )来实现的。

python2.4新加入了subprocess模块,而且官方建议使用改模块替换os.system所以,也可以这样写:

subprocess.call("pause",shell=True)

众多python培训视频,尽在python学习网,欢迎在线学习!

网页题目:创新互联Python教程:怎么停止python脚本
本文链接:http://www.hantingmc.com/qtweb/news9/160209.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联