代码点读机 / Python / decode

decode Python · bytes 方法

把字节串按指定编码转回字符串。

怎么用

字节串.decode(编码='utf-8')

小例子

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

运行结果

你好

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#bytes.decode

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条