开发者

Problem bytes to str

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜