尝试读取graphml文件时无效的连续字节

时间:2018-10-11 16:07:50

标签: python unicode byte decode networkx

我用networkx创建了一个graphml文件。当我尝试阅读它时:

test.com 
test.fr

我收到此错误:

graph = nx.read_graphml(graph_path)

我确定文件中应该有任何奇怪的字符,但仍然无法正常工作。在读取文件之前,我必须先解码文件吗?这有可能吗?

谢谢您的帮助!

编辑: 这是图形的构建方式:

File "/usr/src/app/application/datasources/preprocess_sources.py", line 96, in create_similarities_dictionary
backend_1   |     graph = nx.read_graphml(graph_path)
backend_1   |   File "<decorator-gen-622>", line 2, in read_graphml
backend_1   |   File "/usr/local/lib/python3.6/site-packages/networkx/utils/decorators.py", line 240, in _open_file
backend_1   |     result = func_to_be_decorated(*new_args, **kwargs)
backend_1   |   File "/usr/local/lib/python3.6/site-packages/networkx/readwrite/graphml.py", line 239, in read_graphml
backend_1   |     glist = list(reader(path=path))
backend_1   |   File "/usr/local/lib/python3.6/site-packages/networkx/readwrite/graphml.py", line 728, in __call__
backend_1   |     self.xml = ElementTree(file=path)
backend_1   |   File "/usr/local/lib/python3.6/xml/etree/ElementTree.py", line 557, in __init__
backend_1   |     self.parse(file)
backend_1   |   File "/usr/local/lib/python3.6/xml/etree/ElementTree.py", line 597, in parse
backend_1   |     self._root = parser._parse_whole(source)
backend_1   | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 1: invalid continuation byte

0 个答案:

没有答案