Python subprocess readlines()?

后端 未结 5 1579
小蘑菇
小蘑菇 2021-01-01 16:46

So I\'m trying to move away from os.popen to subprocess.popen as recommended by the user guide. The only trouble I\'m having is I can\'t seem to find a way of making readli

5条回答
  •  死守一世寂寞
    2021-01-01 17:06

    list = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE).communicate()[0].splitlines()
    

    straight from the help(subprocess)

提交回复
热议问题