我正在查询从 MySQL 工作台返回以下值的数据库:
征服者维多利亚
应显示为:
维多利亚达康基斯塔
无论我尝试了什么,我都无法将 'Vit\xc3\xb3ria da Conquista' 转换为 'Vitória da Conquista'
#Querying MySQL "world" database
print "====================================="
query = 'select name from city where id=283;'
cursor.execute(query)
cities = cursor.fetchall()
print cities
for city in cities:
cs = str(city)
cs = cs[3:-3].decode('utf-8')
print cs
print cs.decode('utf-8')
print cs.encode('ascii','ignore')
其输出如下所示:
=====================================
[(u'Vit\xc3\xb3ria da Conquista',)]
Vit\xc3\xb3ria da Conquista
Vit\xc3\xb3ria da Conquista
Vit\xc3\xb3ria da Conquista