Convert bytes to a string

后端 未结 19 2866
野性不改
野性不改 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:03

    I made a function to clean a list

    def cleanLists(self, lista):
        lista = [x.strip() for x in lista]
        lista = [x.replace('\n', '') for x in lista]
        lista = [x.replace('\b', '') for x in lista]
        lista = [x.encode('utf8') for x in lista]
        lista = [x.decode('utf8') for x in lista]
    
        return lista
    

提交回复
热议问题