无法在networkx中读取已由networkx nx.write_graphml编写的Graphml

时间:2015-03-21 17:38:21

标签: python-2.7 networkx

我使用nx.write_graphml编写了一个graphml文件但是当我尝试将其读回时我得到了以下错误

>>> g = nx.DiGraph()
>>> g = nx.read_graphml('cit89.graphml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in read_graphml
  File "/usr/local/lib/python2.7/dist-packages/networkx/utils/decorators.py", line 220, in _open_file
    result = func(*new_args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 153, in read_graphml
    glist=list(reader(path=path))
  File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 405, in __call__
    yield self.make_graph(g, keys, defaults)
  File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 431, in make_graph
    self.add_node(G, node_xml, graphml_keys)
  File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/graphml.py", line 456, in add_node
    node_id = self.node_type(node_xml.get("id"))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128)

0 个答案:

没有答案