Changing default encoding of Python?

3 years ago
Posted by andri
Board Tutorial
437 views


Here is a simpler method (trick) that gives you back thesetdefaultencoding()function that was deleted fromsys:

 
# sys.setdefaultencoding() does not exist, here!
import sys
reload(sys)  # Reload does the trick!
sys.setdefaultencoding('UTF8')
 

And change mysql database field to utf8_unicode_ci

Source :stackoverflow.com