os.popen(cmd) .read() 获取执行后的结果且带有换行符\n
时间:2018-04-14 10:43:23
收藏:0
阅读:1161
os.popen(cmd) .read() 获取执行后的结果自动带有换行符\n
>>> a=os.popen("ls ./soapnuke_output/CL100006359_L01_8 |wc -l")
>>> a
<open file ‘ls ./soapnuke_output/CL100006359_L01_8 |wc -l‘, mode ‘r‘ at 0x7f66e8038c00>
>>> a.read
<built-in method read of file object at 0x7f66e8038c00>
>>> a.read()
‘17\n‘
>>> b=os.popen("echo bb")
>>> b
<open file ‘echo bb‘, mode ‘r‘ at 0x7f66e8038c90>
>>> b.read()
‘bb\n‘
原文:https://www.cnblogs.com/koujiaodahan/p/8830455.html
评论(0)