string与bytes相互转化


按uft-8形式编码   
a=’hello world’
b=a.encode(encoding=’utf-8’)
print(type(a), tyoding=’utf-8’)
print(c, type(c))

按gbk方式编码
x=a.encode(encoding=’gbk’)
print(x, type(x))
y=x.decode()
print(y, type(y))


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM