os.popen()使用小记
来源:互联网 发布:网络作家年收入排名 编辑:程序博客网 时间:2024/05/18 09:25
一场人与机器的较量 人用了一下午的青春打败了机器。。。。死了N多脑细胞
起初的目的是为了获取os.popen的返回值用来做判断。
然而因为Linux上的换行符与win上的不同,导致测试一直出错
import osa = os.popen("echo 'hello'")b = a.read()print bif b == "'hello'\n" : print "yes"else: print "no"
上面的代码在win上运行结果是
yes
而在Linux(centos)上运行结果为
no
os.popen最初赋值给a,并不能直接读出,用print也不行
需要用read()或者readlines()得到字符串b
print b
显示
‘hello’
直接输入b得
‘hello’\n
0 0
- os.popen()使用小记
- os.popen
- os.popen()
- python 关闭 os.popen()
- python os.popen os.system
- python中os.system、os.popen、subprocess.popen的区别
- python os.popen 超时问题
- os.system() 和os.popen()的区别
- python os.system os.popen 区别
- python os.popen与os.system区别
- python os.system os.popen 区别
- python os.system()和os.popen()
- python os.popen()和os.system()区别
- python中os.popen, os.system()区别
- 使用os.popen/commands.getoutput查询指定端口号的服务
- 关于python中os.system,os.popen,os.comands
- Linux popen()函数使用
- popen 使用总结
- 关于嵌入式面试的一些题
- 本周总结
- 08_多线程之JOIN
- Android 更新UI的两种方式
- 使用 CXF 做 webservice 简单例子(转载)
- os.popen()使用小记
- 浅谈系统密码加密方式
- 常用Git命令行总结
- 串口通讯中的DCB结构
- Handshake failed due to invalid Upgrade header: null
- iOS,如何模仿一个App
- Support v4 24.2.0 更新看点
- Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id)等
- hdu 1978 How Many Ways