执行Python时暂停执行的几种方法
有时候我们在执行python文件的时候,想让程序暂停下来方便我们看到输出打印的信息方便调试以下几种方式,可以实现让程序暂停下来
1)方法一:
通过time中sleep函数
time.sleep(secs)
2)通过等待输入让程序暂定
input or raw_input
3)通过os.system执行系统暂停pause函数
import os
os.system("pause")
也可以通过subprocess模块,官方建议使用该模块替换os.system模块
import subprocess
subprocess.call("pause",shell=true)
标签: python subprocess input time
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)