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'

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-07-13
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-09-04
  • 2021-12-21
  • 2022-12-23
相关资源
相似解决方案