Issues while writing HTML file

36 views Asked by At

Problem

Why can't I set this variable html_str equal to the wikisum string variable? Is it a simple syntax error?

Code

import wikipedia
from django.db import models
from django.template import Template, Context
wikisum = wikipedia.summary("Julius Caesar", sentences=2)
print wikisum
html_str = wikisum
Html_file= open("index.html","w")
Html_file.write(html_str)
Html_file.close()

Thanks!

Btw the error was:

  • UnicodeEncodeError: 'ascii' codec can't encode characters in position 39-40: ordinal not in range(128)
0

There are 0 answers