基本上,我只是想在编辑后将一个字符串写入文件,作为概念验证,我只是想做出应该是毫无意义的改变。但是,如下例所示,即使这样也会由于某种原因使我的输出大小加倍。有谁知道为什么会这样?
content = StringIO.getvalue()
with open("real.png", 'wb') as dump:
dump.write(content) #35KB
content = [str(ord(char)) for char in content]
content = "".join([hex(int(char)).lstrip("0x").zfill(2) for char in content])
with open("new.png", "wb") as dump:
dump.write(content) #70KB