ascii codec cant decode byte 0xe9

后端 未结 4 490
说谎
说谎 2021-01-18 11:37

I have done some research and seen solutions but none have worked for me.

Python - 'ascii' codec can't decode byte

This didn\'t work for me. And

4条回答
  •  醉梦人生
    2021-01-18 12:32

    Based on what you want to do with your lines, you can do different work here, if you just want to print in consul as normally the consuls use utf8 encoding you dont need to do that by your self as the format of your string is not unicode:

    >>> output_string = '\n'.join(output_lines)
    >>> print output_string
    
    
    
    
    
    
    Cream of Wheat (Farina)
    
    
    
    
    
     
    

    But if you want to write to file you can use codecs module:

    import codecs
    f= codecs.open('out_file','w',encoding='utf8')
    

提交回复
热议问题