I'm learning Python and playing around with a Reddit bot, but I'm getting an error. I think I need to change the encoding of the PowerShell console window, but I'm not sure how. Here is the code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import praw
user_agent = ("PyEng Bot 0.1")
r = praw.Reddit(user_agent = user_agent)
subreddit = r.get_subreddit("learnpython")
for submission in subreddit.get_hot(limit = 5):
print "Title: ", submission.title
print "Text: ", submission.selftext
print "Score: ", submission.score
print "---------------------------------\n"
And here is the error:
Text: Traceback (most recent call last):
File "redditbot.py", line 13, in <module>
print "Text: ", submission.selftext
File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2014' in position 204: character maps to <undefined>