Q:

Python Not Accepting UTF-8 Coding

I'm trying to write a Python script that uses UTF-8 information, but I'm getting SyntaxError: Non-ASCII character messages.
It looks like I can solve this by adding the following to the top of my script:
#!/usr/bin/python
# coding: utf8

But I get ascii when I run this script:
#!/usr/bin/python
# coding: utf8
import sys
print sys.getdefaultencoding()

Also, I've tried with the same results:
#!/usr/bin/python
# -*- coding: utf-8 -*-

Why isn't my script using UTF-8?

A:

You can set it to utf-8 as:
import sys
reload(sys)
sys.setdefaultencoding("utf8")

