码迷,mamicode.com
首页 > 其他好文 > 详细

bytearray 字符串转为字节

时间:2019-07-20 10:01:46      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:control   hello   array   bsp   str   play   audio   decode   bytearray   

 

>>> str="hello world"
>>> x=bytearray(str)
>>> x
bytearray(b‘hello world‘)
>>> x.decode()
u‘hello world‘


>>>bytearray()
bytearray(b‘‘)
>>> bytearray([1,2,3])
bytearray(b‘\x01\x02\x03‘)
>>> bytearray(‘runoob‘, ‘utf-8‘)
bytearray(b‘runoob‘)
>>>

bytearray 字符串转为字节

标签:control   hello   array   bsp   str   play   audio   decode   bytearray   

原文地址:https://www.cnblogs.com/sea-stream/p/11216566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!