python中的gzdecode文件

时间:2015-03-21 17:09:50

标签: python gzip gz

我有一个错误使用这个,我不明白

import glob
import zlib
import sys

for filename in sys.argv:
    with open(filename, 'r') as compressed:
        with open(filename + "-decompressed', 'w') as expanded:
        data = zlib.decompress(compressed.read())
        expanded.write(data)

错误

    with open(filename + "-decompressed', 'w') as expanded:
                                                          ^
SyntaxError: EOL while scanning string literal

TY

1 个答案:

答案 0 :(得分:0)

您偶然使用一个双引号和一个单引号来关闭字符串。应该是

 with open(filename + '-decompressed', 'w') as expanded: