pygexf
pygexf copied to clipboard
problem with coding with python3
I ran the demo:
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)
but I built with python3, I got:
TypeError: write() argument must be str, not bytes
even though I know that the source code is telling us:
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()
what's wrong?
use "wb" instead of "w"