实际上,我正在创建一个列表,其中我将整数转换为具有8位表示的二进制数字,并将二进制数据写入excel电子表格:
row = 3
for x in MyList:
mybinary = bin(x)[2:].zfill(8)
ws.write(r,2,mybinary)
row+=1
位应该具有相同的顺序,但只是从右侧开始在8行上排序
调试信息:
print(type(MyList))
<type 'list'>
print(type(x))
<type 'int'>
<type 'int'>
<type 'int'>
<type 'int'>
<type 'int'>
到目前为止,mybinary的输出是正常的(在excel工作表中输出的二进制字符串),并且转换正确
有什么想法吗
用上面两行替换
ws.write(r,2,mybinary)
语句就可以了相关问题 更多 >
编程相关推荐