22智能在线
新记
python3 中如何进bytes串转换成str?
比如:
a = b'123'
想变成:
a = '123'
举报该文章
相关建议 推荐于2016-04-18
bytes解码会得到str
str编码会变成bytes
>>> b'123'.decode('ascii')
'123'
>>> '123'.encode('ascii')
b'123'
温馨提示:内容为网友见解,仅供参考
当前网址:
https://22.t2y.org/zz/cs0ct0xxtsft26c2sxh.html
其他看法
第1个回答 2017-09-12
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = b'123'
>>> a.decode()
'123'
第2个回答 2017-10-12
b'123'.decode()
结果是'123'
相似回答
大家正在搜
相关问题
python3 str类型中存在bytes型 怎么进行转换
python3里的bytes和str还有int有什么区别
python3 bytes decode成字符串后内容改变
python3 bytes转字符串的问题
python怎么把01字符串转为二进制bytes串?
python3转成bytes其中bytes()与encode...
请问python中这字符串转bytes怎么做算的?
python3 报错'str' object has no ...