os.popen(cmd) .read() 獲取執行后的結果且帶有換行符\n


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'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM