2016-05-21 4 views
-1

このコードはPython 2.7バージョンで実行しています。PythonのギリシャアルファベットのUnicodeコード

import sys, os 
sys.path.append(os.path.join(os.path.split(os.path.abspath(__file__))[0], 'lib')) 
from bottle import route, run, static_file, request 
import pymysql as db 
import settings 

con = db.connect(
    settings.mysql_host, 
    settings.mysql_user, 
    settings.mysql_passwd, 
    settings.mysql_schema, 
    charset='utf8', 
    use_unicode=True) 

cur = con.cursor() 

cur.execute("SELECT tragoudi.titlos, tragoudi.etos_par, cd_production.etaireia FROM tragoudi JOIN singer_prod ON tragoudi.titlos=singer_prod.title JOIN cd_production ON singer_prod.cd=cd_production.code_cd GROUP BY tragoudi.titlos HAVING tragoudi.titlos LIKE %s AND tragoudi.etos_par LIKE %s AND cd_production.etaireia LIKE %s",("ΑΓΩΝΙΑ","1978","SONY")) 
con.commit() 

#cur.execute("SELECT * FROM kalitexnis") 


for row in cur.fetchall(): 
    table = row[:] 

print table 
con.close() 

、それがこの結果として私を与える:単語のユニコードが「ΑΓΩΝΙΑがA=\u0391Γ=\u0393など あるので

(u'\u0391\u0393\u03a9\u039d\u0399\u0391', 1978, u'SONY') 

正しいあるだから私の質問がある場合ということですPythonの2がそう、それはUnicode文字列であることを知らせるための接頭辞としてUを使用しています

(u'ΑΓΩΝΙΑ', 1978, u'SONY') 
+1

あなた '印刷テーブルであれば[0]'それはまた、引用符と 'u'の除去、正しく文字が表示されます。タプルは要素の 'repr'を示します。本当にあなたが示したものが本当に必要ですか? –

+0

これは多分あなたを助けるでしょう [アラビア語のテキストをPyQt4からUTF-8に変換する方法](http://stackoverflow.com/questions/36220459/how-to-convert-arabic-text-from-pyqt4-to -utf-8?answertab =最古の#tab-top) – FRe34

答えて

0

結果として私print tableを取得する方法リスト要素を要素ごとに出力すると、正しく出力されます。だから、

for x in table 
    print x