python os 模块学习
2014-12-11 18:20
281 查看
2.os.popen() 功能强于os.system() , os.popen() 可以返回回显的内容,以文件描述符返回。
eg:
t_f = os.popen ("ping 192.168.1.1")
print t_f.read()
或者:
for line in os.popen("dir"):
print
line
os.system() 和os.popen()的区别
返回的数据不同
1 os.system(“ls") 返回0
但是这样是无法获得到输出和返回值的
继续 Google,之后学会了 os.popen()。 view sourceprint?
a... output = os.popen('cat /proc/cpuinfo')
b... print output.read()
eg:
t_f = os.popen ("ping 192.168.1.1")
print t_f.read()
或者:
for line in os.popen("dir"):
line
os.system() 和os.popen()的区别
返回的数据不同
1 os.system(“ls") 返回0
但是这样是无法获得到输出和返回值的
继续 Google,之后学会了 os.popen()。 view sourceprint?
a... output = os.popen('cat /proc/cpuinfo')
b... print output.read()
相关文章推荐
- python学习---4(python os模块)
- python模块学习——os
- Python学习18:os标准库模块使用(一)
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python模块学习之os常用函数
- python os.path模块学习
- Python OS模块学习(一)
- python-os模块学习
- Python学习笔记之os模块使用总结
- Python的学习(二十五)-- os.path模块
- python标准库os模块学习
- python os模块学习
- Python学习18:os标准库模块使用(二),path模块使用
- Python学习笔记 OS模块
- python os.path模块学习
- python os模块的学习
- Python 学习笔记 (7)—— OS模块
- Python学习-32.Python中os模块的一些方法
- Python 模块学习:os模块