Table Of Contents

m

全干工程师

convert bytes to a string in python?

可以在python命令行测试下面代码

>>> b"abcde"
b'abcde'

# utf-8 is used here because it is a very common encoding, but you
# need to use the encoding your data is actually in.
>>> b"abcde".decode("utf-8") 
'abcde'

>>> print b"\xe4\xbd\xa0\xe5\xa5\xbd".decode("utf-8")
'你好'

留言