寫一個簡單的應用,用MySQLdb將Mysql中的內容讀出並顯示到web。
由於MySQL中默認是latin1編碼,MySQLdb雖可以設置連接編碼,用盡各種unicode\encode\decode還是顯示亂碼。
最後只能出絕招了:使用%s格式化輸出,可得到正確結果。
原文地址:http://nourlcn.ownlinux.net/2011/10/python-mysql-web.html
寫一個簡單的應用,用MySQLdb將Mysql中的內容讀出並顯示到web。
由於MySQL中默認是latin1編碼,MySQLdb雖可以設置連接編碼,用盡各種unicode\encode\decode還是顯示亂碼。
最後只能出絕招了:使用%s格式化輸出,可得到正確結果。
原文地址:http://nourlcn.ownlinux.net/2011/10/python-mysql-web.html
class MetaCls(type): def __new__(cls, *args, **kwargs): print("in MetaCls") # return super(Meta