0
美好的一天,需要轉換來自數據庫的解碼字符串
我有一個問題,下面的代碼給了我下面的結果。
'你好'] ['Unterl \ xc3 \ xa4nderstr。 46'] ['Weilimdorf B \ xc3 \ xbcrohaus'] ['Property Name'] ['你好在另一邊'] ['Jahnstra \ xc3 \ x9fe'] ['Bahnhofstr。 15'] ['Karlsruher Str。 3'] ['Bahnhofstra \ xc3 \ x9fe 69'] ['Florians Haus'] ['屬性號碼22'] ['Schickardstr.36'] ['Clichystr。 6'] ['Property Name 2'] ['Kirchstra \ xc3 \ x9fe 5']無
我需要\ xc3 \ xa4顯示爲它們對應的UTF-8字母,但無法獲取它跑。我希望這裏有人有類似的問題。
import cgi
import cgitb
cgitb.enable()
import sqlanydb
def db_dropdown():
con = sqlanydb.connect(userid="DB", pwd="123", eng='DB',dbn='DB')
cursor = con.cursor()
sql ="select distinct [Property] from Asset_Zielfonds"
cursor.execute(sql)
rowset = cursor.fetchall()
encoded = [[s.encode('utf8') for s in t] for t in rowset]
return encoded
def print_dropdown(data): # Print the dropdown
print '<div>'
#print '<select>'
for i in data:
print '%s' % (i)
#print '</select>'
print '</div>'
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<meta charset="ISO-8859-1">'
print '<head>'
print '</head>'
print '<body>'
print '<h2>Retrieval of Data from DB</h2>'
print '<br>'
print '<br>'
print '<br>'
print print_dropdown(db_dropdown())
print '<br>'
print '<br>'
print '<br>'
print '</body>'
print '</html>'