使用python3进行gexf编程

时间:2018-08-06 12:36:41

标签: python-3.x graphics

我测试了演示:

from gexf import 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构建,我得到了:

  

TypeError:write()参数必须为str,而不是字节   但我知道源代码告诉我们:

def write(self, file, print_stat=True):
  file.write(etree.tostring(self.getXML(), pretty_print=True, encoding='utf-8', xml_declaration=True))
  if print_stat is True:
           self.print_stat()

怎么了?

0 个答案:

没有答案