我有以下二进制字符串
In [32]: print(codes)
['01000011', '01101111', '01101101', '01110000', '01110101', '01110100', '01100101', '01110010', '00100000', '01010011', '01100011', '01101001', '01100101', '01101110', '01100011', '01100101']
将它们解码为
In [33]: for c in codes:
...: print(chr(int(c, 2)))
...:
C
o
m
p
u
t
e
r
S
c
i
e
n
c
e
以隐式'/ n'印刷文本
如何在一行中打印输出?
答案 0 :(得分:2)
codes = ['01000011', '01101111', '01101101', '01110000', '01110101', '01110100', '01100101', '01110010', '00100000', '01010011', '01100011', '01101001', '01100101', '01101110', '01100011', '01100101']
print codes
test = ''
for c in codes:
test += (chr(int(c,2)))
print test