I am using facebook graph API but getting error when I try to run graph.py How should I resolve this problem of charmap. I am facing unicode decode error.
In graph.py :
table = json2html.convert(json = variable)
htmlfile=table.encode('utf-8')
f = open('Table.html','wb')
f.write(htmlfile)
f.close()
# replacing '>' with '>' and '<' with '<'
f = open('Table.html','r')
s=f.read()
s=s.replace(">",">")
s=s.replace("<","<")
f.close()
# writting content to html file
f = open('Table.html','w')
f.write(s)
f.close()
# output
webbrowser.open("Table.html")
else:
print("We couldn't find anything for",PageName)
I could not understand why I am facing this issue. Also getting some error with 's=f.read()'
latin-1-open(..., encode="latin-1")Use Google to check in what encoding is char0x8dhtmlfileand save it and then you don't need to open it again.htmlfileand save it. In error message I see it tries to guess encoding in file when you read it and finally it uses encodingcp1250to read it (probably because Windows usecp1250as default in system). So next time useopen( ..., encoding='utf-8')so it will not guessing.