2
我是新來的金字塔。我使用python2.7,MSSQL,slqalchemy.mssql並使用gbk
字符集,並且我有很多舊數據。所以我改變前的HTML編碼爲gbk
,使用下面的代碼:金字塔是否可以將默認的request.charset從utf-8更改爲gbk?
@view_config(route_name='g', renderer='json')
def my_view1(request):
print 2
print request.charset
print 1
print isinstance(request.params['one'], str)
if request.params['one']:
print request.params['one']
filters = (Bzjl.one == request.params['one'])
try:
two1 = DBSession.query(Bzjl).filter(filters)
except DBAPIError:
return Response(conn_err_msg, content_type='text/plain', status_int=500)
return Response(getjson(two1))
例如網址:http://127.0.0.1:6543/g?one='中國福建'
返回行:{"records": 0, "total": 20, "rows": [], "page": 1}