google app engine python 汉字编码问题

参考 http://www.makenotes.net/?p=1001

google app engine 的request,response默认都是utf-8
我想用urlfetch.fetch(url)抓取cnbeta,cnbeta编码是GB2312

所以要这么写

    def get(self):
        self.request.charset='GB2312'
        url = "http://www.cnbeta.com/"
        result = urlfetch.fetch(url)
        
                self.response.charset='GB2312'
        self.response.headers['Content-Type'] = 'text/html;charset=GB2312'
        self.response.out.write(result.content)

你可能感兴趣的:(html,.net,python,Google)