我正在使用 python 包 networkx
并有一个 MultiDigraph
,我想将它保存为 graphml 格式,以便在另一个软件中使用它进行进一步分析。我也有一个节点和边属性。
我使用了 bellow 命令,但没有用。此命令似乎不适用于 MultiDigraph
。
nx.write_graphml(G, 'C:\\hm\\HMGraph.gml')
这是我得到的错误:
nx.write_graphml(G, 'C:\\hm\\HMGraph.gml')
Traceback (most recent call last):
File "<ipython-input-5-e35c8921ea4a>", line 1, in <module>
nx.write_graphml(G, 'C:\\hm\\HMGraph.gml')
File "<decorator-gen-809>", line 2, in write_graphml_lxml
File "C:\Users\xparve\Anaconda3\lib\site-packages\networkx\utils\decorators.py", line 239, in _open_file
result = func_to_be_decorated(*new_args, **kwargs)
File "C:\Users\xparve\Anaconda3\lib\site-packages\networkx\readwrite\graphml.py", line 153, in write_graphml_lxml
writer = GraphMLWriterLxml(
File "C:\Users\xparve\Anaconda3\lib\site-packages\networkx\readwrite\graphml.py", line 664, in __init__
self.add_graph_element(graph)
File "C:\Users\xparve\Anaconda3\lib\site-packages\networkx\readwrite\graphml.py", line 714, in add_graph_element
T = self.xml_type[self.attr_type(k, "edge", v)]
KeyError: <class 'datetime.datetime'>
有人可以帮忙吗?
答案 0 :(得分:1)