Convert bytes to a string

后端 未结 19 2239
野性不改
野性不改 2020-11-21 04:45

I\'m using this code to get standard output from an external program:

>>> from subprocess import *
>>> command_stdout = Popen([\'ls\', \'-l         


        
19条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 05:08

    Set universal_newlines to True, i.e.

    command_stdout = Popen(['ls', '-l'], stdout=PIPE, universal_newlines=True).communicate()[0]
    

提交回复
热议问题