[Tutor] Unicode Encode Error

Aaron Misquith aaronmisquith at gmail.com
Tue Jun 17 09:30:56 CEST 2014


I'm trying to obtain the questions present in StackOverflow for a
particular tag.

Whenever I try to run the program i get this *error:*

Message File Name Line Position
Traceback
    <module> C:\Users\Aaron\Desktop\question.py 20
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in
position 34: ordinal not in range(128)


*This is the code:*
import stackexchange
import sys
sys.path.append('.')
so = stackexchange.Site(stackexchange.StackOverflow)
term= raw_input("Enter the keyword")
print 'Searching for %s...' % term,
sys.stdout.flush()
qs = so.search(intitle=term)

for q in qs:
   print '%8d %s' % (q.id, q.title)
   with open('D:\ques.txt', 'a+') as question:
       question.write(q.title)

Can anyone explain me what is going wrong here? This program used to run
perfectly fine before. Only since yesterday I have started getting this
error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140617/5a739820/attachment.html>


More information about the Tutor mailing list