在官网上的程序
from gexf import Gexf
# test helloworld.gexf
gexf = Gexf("Paul Girard","A hello world! file")
graph=gexf.addGraph("directed","static","a hello world graph")
graph.addNode("0","hello")
graph.addNode("1","World")
graph.addEdge("0","0","1")
output_file=open("hellowrld.gexf","w")
gexf.write(output_file)
无法写入,如果是python3嵌入版本可以尝试将"w"改为"wb",楼主是在anaconda python2.7 的虚拟环境下,仍然无法写入。程序不报错但是写入的文件为空白文件。
将最后一行改为
gexf.write(file=output_file)
成功写入