Suppress/ print without b' prefix for bytes in Python 3

前端 未结 5 887
野性不改
野性不改 2020-11-28 08:13

Just posting this so I can search for it later, as it always seems to stump me:

$ python3.2
Python 3.2 (r32:88445, Oct 20 2012, 14:09:50) 
[GCC 4.5.2] on lin         


        
5条回答
  •  执笔经年
    2020-11-28 09:01

    you can use this code for showing or print :

    .decode("utf-8")
    

    and you can use this for encode or saving :

    .encode('utf-8')
    

提交回复
热议问题