将八进制字符转换为字符串

在使用protobuf时,pb的中文打印出来经常是八进制字符列表,如下:

task_name:"[\345\207\272\345\272\223\351\224\231\350\257\257]

根本不知道是什么意思,此时需要工具将其转换为字符串。

转换工具代码如下:

import chardet

a = b"345207272345272223351224231350257257"
fencoding = chardet.detect(a)
a = a.decode('utf-8')
print(a)

结果就很清晰le :

出库错误

原文地址:https://www.cnblogs.com/moodlxs/p/15032105.html