首页 > 编程语言 > 详细

编码和Python的bytearray , bytes

时间:2016-07-11 01:24:24      阅读:240      评论:0      收藏:0      [点我收藏+]

unicode    是  编码规范          ===》 http协议


GBK UTF-8  是 字符集  编码方法   ===》 Apache  nginx


Python 3.X

bytes 和 str 的区别在于bytes是byte的序列,而str是Unicode的序列



http://www.asciitable.com/

b‘6‘.hex()  ==>  16进制

‘36’


int(b‘6‘.hex(), 16)  ==>  10 进制

54


b1 = b‘1234‘

b2 = bytearray(b1)


b2

Out[27]: bytearray(b‘1234‘)


b2[0] = int(b‘6‘.hex(), 16)

b2

Out[29]: bytearray(b‘6234‘)


bytes(b2)

Out[31]: b‘6234‘


b1 = bytes(b2)

b1

Out[33]: b‘6234‘







本文出自 “大荒芜经” 博客,请务必保留此出处http://2892931976.blog.51cto.com/5396534/1816789

编码和Python的bytearray , bytes

原文:http://2892931976.blog.51cto.com/5396534/1816789

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!