我不明白为什么这应该这么难。
你到底在做什么 请解释“最终它读取了无效字符”。
它应该很简单:
import gzip
fp = gzip.open('foo.gz')
contents = fp.read() # contents Now has the uncompressed bytes of foo.gz
fp.close()
u_str = contents.decode('utf-8') # u_str is Now a unicode string
在python中从gzip文件读取utf-8字符
我不明白为什么这应该这么难。
你到底在做什么 请解释“最终它读取了无效字符”。
它应该很简单:
import gzip
fp = gzip.open('foo.gz')
contents = fp.read() # contents Now has the uncompressed bytes of foo.gz
fp.close()
u_str = contents.decode('utf-8') # u_str is Now a unicode string