pygexf icon indicating copy to clipboard operation
pygexf copied to clipboard

problem with coding with python3

Open davendw49 opened this issue 6 years ago • 1 comments

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?

davendw49 avatar Aug 06 '18 12:08 davendw49

use "wb" instead of "w"

UncleGedd avatar Aug 24 '19 19:08 UncleGedd