【发布时间】:2016-04-04 11:40:57
【问题描述】:
我正在用 python 3.5 解析一个 xml 文件(291 MB)
import xmltodict, json
with open('Wikipedia-20160404094133.xml', encoding='utf-8') as xml_file:
dic_xml = xmltodict.parse(xml_file.read(), encoding='utf-8', xml_attribs=True)
但我得到了错误:
dic_xml = xmltodict.parse(xml_file.read(), encoding='utf-8', xml_attribs=True)
MemoryError
我能做些什么来解决这个问题?
【问题讨论】:
-
在任何相对现代的系统上,我都不认为这会导致内存错误 - 您是在共享服务器上运行还是在 RAM 有限的云上运行?
-
您需要提供有关您正在运行的系统和您的 python 安装的更多信息。