问题
pipe.setnx(prefix+item[0], gzip.compress(bytes(item[1], 'utf-8')))
I'm trying to compress a file using the gzip python lib on an EC2 instance. I assume that gzip is part of the standard library. However, I get the following error
AttributeError: 'module' object has no attribute 'compress'
回答1:
I figured out that someone else had added a library called gzip. So, it was defaulting to that one and the not standard library. I ended up using zlib instead.
来源:https://stackoverflow.com/questions/51216128/gzip-python3-attributeerror-module-object-has-no-attribute-compress