0
我有這個應用程序在python 2.7中正常工作完全!Django:在Django中找不到編碼
它以「من」爲例,並將其更改爲「mn」。
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
"""Kurdish Alphabet to Kurdish Kirmanci Latin Translator"""
s = "من"
Latin = {
'ئه':'A','ا':'A','ب':'B',
'ج':'C','چ':'Ç','د':'D',
'ە':'E','ێ':'Ê','ف':'F',
'گ':'G','ه':'H','هه':'Ha',
'ئ':'I','ی':'Î','ژ':'J',
'ک':'K','ل':'L','م':'M','ن':'N',
'ۆ':'O','پ':'P','ق':'Q','ر':'R',
'س':'S','ش':'Ş','ت':'T',
'وو':'U','و':'Ú','ی':'Y','ز':'Z',
'خ':'X',' ':' ','؟':'?','،':',',}
#this will take each index of the list
#and take it through ChangeTool
#and print it
wordlist = list(s)
wordlist = [ch for ch in s]
for l in wordlist:
print (Latin[l])
print("\r")
現在我已經改變了這一個Django的功能,我得到奇怪的行爲!
Django的功能:
def change(request):
Latin = {'ئه','ا','ب','ج','چ',}
Latin = [character for character in Latin]
return render_to_response('change_result.html',{'Latin':Latin})
我只是想試探會是怎樣的結局!現在這是在HTML頁面中顯示的內容:
['\xd8\xa6\xd9\x87', '\xda\x86', '\xd8\xa8', '\xd8\xac', '\xd8\xa7']
如果我把u''
在信的前面,這是什麼出來:
[u'\u0628', u'\u0626\u0647', u'\u062c', u'\u0627', u'\u0686']
有人可以請請請你告訴我發生了什麼?爲什麼這些字母沒有顯示在html頁面上?
您是否在html中設置了? – linbo 2013-03-16 08:57:57
是的,我在HTML頁面也有 ! – 0bserver07 2013-03-16 09:41:00