如何阅读zip文本文件?

时间:2019-01-16 19:15:17

标签: python word2vec

我正在尝试在python中读取压缩文件(.gz),但遇到了麻烦。

import gzip
import gensim
import logging
import os

logging.basicConfig(
    format='%(asctime)s : %(levelname)s : %(message)s',
    level=logging.INFO)

data_file = r"C:\\PythonProgs\\OpinRank.gz"

def show_file_contents(input_file):
    with gzip.open(input_file, 'rb') as f:
        for i, line in enumerate(f):
            print(line)
            break


show_file_contents(data_file)

我希望阅读zip文件,但实际上给我这个错误:

FileNotFoundError:[错误2]没有这样的文件或目录:'C:\ PythonProgs \ OpinRank.gz'

0 个答案:

没有答案
相关问题