2013-03-05 20 views
0

我發現,其中包括外國文字使用Python的雙字母組的列表:阿拉伯語,俄語,波斯語Python的兩字 - 外國文字

結果顯示爲這樣的:('\ xd9 \ X85 \ xd9 \ 86 \ XD8 \ xa7 \ xd8 \ xd9 \ x87','\ xd9 \ x85 \ xd9 \ x88 \ xd8 \ xb3 \ xd9 \ x88 \ xdb \ x8c')

這個腳本叫什麼?我將它轉換爲阿拉伯文/俄文/波斯文副本。

我正在使用NLTK在MAC OS的終端上運行此操作。

回答

2

這是包含UTF-8編碼的文本字節字符串:

In [5]: '\xd9\x85\xd9\x86\xd8\xa7\xd8\xb8\xd8\xb1\xd9\x87'.decode('utf-8') 
Out[5]: u'\u0645\u0646\u0627\u0638\u0631\u0647' 

In [6]: print '\xd9\x85\xd9\x86\xd8\xa7\xd8\xb8\xd8\xb1\xd9\x87'.decode('utf-8')   
مناظره 
+0

我發現這一點:http://docs.python.org/2/howto/unicode.html是一個很好的導向爲Unicode。 – emschorsch 2013-03-05 17:14:16

+1

[This is also a must-read。](http://joelonsoftware.com/articles/Unicode.html) – 2013-03-05 17:15:43

+0

謝謝!!!!!! – user1011332 2013-03-05 17:23:06