我正试图将这段代码转换为在Python3中使用,但我不知道如何使它在int和byte对象之间不再存在cancat的情况下工作。 编辑:这可以工作,但会导致一个新的错误在这里它链接到完整的文件:https://github.com/ndye/tiboyce/blob/master/conv_skin.py
主要的错误是现在的数据都在内存中,等待写入它是给我这个错误
Traceback (most recent call last):
File "conv_skin2.py", line 42, in <module>
to_append = ',' * comma + '$%02X' % ord(byte)
TypeError: ord() expected string of length 1, but int found
def compress(data):
return chr(len(data) % 256) + chr(len(data) / 256) \
+ lzf.compress(data)
您只需在串联之前将字符串转换为字节:
见How to cast a string to bytes without encoding
相关问题 更多 >
编程相关推荐