1

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)
Joe
  • 46,419
  • 33
  • 155
  • 245
Dalí
  • 102
  • 1
  • 9
  • 1
    How about changing the title... its not a syntax error. Which line is the error on? The solution may be `html_str.encode('utf-8')`. – tdelaney Dec 09 '14 at 23:10

0 Answers0