pu369com

2024年3月15日

python bytes格式的一些转换

摘要: import binascii #中文字符串转bytes s = "中国" b = s.encode("utf-8") print(b) #输出:b'\xe4\xb8\xad\xe5\x9b\xbd' #bytes转字符串,默认utf-8解码 print(b.decode()) #输出:中国 #16 阅读全文

posted @ 2024-03-15 13:27 pu369com 阅读(15) 评论(0) 推荐(0) 编辑

导航