开发者

Problem bytes to str

开发者 https://www.devze.com 2023-02-06 03:21 出处:网络
I\'m new in jython and I try to convert bytes to str. do yo开发者_运维问答u know how I can do this?

I'm new in jython and I try to convert bytes to str.

do yo开发者_运维问答u know how I can do this? Thanks


from array import array

a = array('b', [30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])
print ', '.join(map(str, a))


try:

from array import array

a = array('b', [30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])

print a.tostring()
print a.tounicode()


You can use String.join() with array as a sequence:

import array
ar = array.array('b', [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47])
ars = ', '.join(str(x) for x in ar)
print(ars)
0

精彩评论

暂无评论...
验证码 换一张
取 消