阿拉伯语编码 - django [英] arabic encode - django
本文介绍了阿拉伯语编码 - django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做
>>> s = unicode('أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟')
Unsupported characters in input
>>> s = u"أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
Unsupported characters in input
>>> s = "أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟".encode('utf-8')
Unsupported characters in input
>>> s = "أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
Unsupported characters in input
但都没有工作。我究竟做错了什么?
but none of them is working. what am I doing wrong?
我有django 1.6和python 2.7
I have django 1.6 and python 2.7
推荐答案
添加此行到你的代码的顶部。它适用于我的希伯来语,阿拉伯语和技术上的任何其他语言。
Add this line to the top of your code. It works for my Hebrew, Arabic, and technically for any other language.
#-*- coding: utf-8 -*-
或者,您可以将其作为原始字符串打印。所以:
Or alternatively, you can print it as a raw string. So:
s = r"أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
print s
这篇关于阿拉伯语编码 - django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文