【发布时间】:2021-07-19 09:18:07
【问题描述】:
for d in range(0,d2.size):
c2 += str(d2.item(d))
cf.write(chr(int(c2,2)))
在 cf.write(chr(int(c1,2))) 中出现错误
TypeError: 需要一个类似字节的对象,而不是 'str'
代码在 python 2.x 上运行良好
【问题讨论】:
-
你能用什么参数发布文件(cf)打开了吗?我认为问题在于您使用 'rb' 参数打开文件。
-
@kinshukdua
cf = open(f+".ctxt","wb") -
我已经发布了一个可以解决您问题的答案。如果是,请投票并选择它作为答案。
标签: python python-3.x string byte