我正在尝试将此循环转换为for循环,但我不知道如何去做。
output = ''
i = 0
while i <len(MyArray):
C = chr(int(MyArray[i],2))
output = output + C
i = i + 1
print(output)
任何帮助将不胜感激
答案 0 :(得分:3)
output = ''
for i in range(len(MyArray)):
C = chr(int(MyArray[i],2))
output = output + C
print(output)
或
output = ''
for element in MyArray:
C = chr(int(element,2))
output = output + C
print(output)
或
output = [chr(int(element,2)) for element in MyArray]
print ''.join(output)