ezoic

Thursday, October 12, 2017

If your web.py read in some garbage character, try this method

I once used the python web.py to set up a web service. But when reading in non English words, it will show garbage characters.

Here is a way to fix that problem.

add the two lines at the top of the script:

#!/usr/bin/env python# -*- coding:utf-8 -*-

Add the lines to the beginning import of the script:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')


Add the header in the get function like below. 




It will solve the problem. 

No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...