如何将正常数字转换成django中的阿拉伯数字 [英] How to convert normal numbers into arabic numbers in django
本文介绍了如何将正常数字转换成django中的阿拉伯数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数字列表[1,2,3,....]
现在我想使用django将它们转换成阿拉伯数字。 p>
可以吗?欢迎任何想法。
解决方案
尝试此功能:
def enToArnumb(number):
dic = {
0:'0',
1:'1',
2:'2' ,
3:'3',
4:'4',
5:'5',
6:'6',
7:'7' ,
8:'8',
9:'9',
。:'0',
}
return dic.get(number)
并使用如下:
ar_numbers = [enToArnumb(num)为数字]
I have a list of numbers [1,2,3,....]
Now i want to convert them into arabic numbers using django.
Is it possible? Any ideas are welcome.
解决方案
try this function:
def enToArNumb(number):
dic = {
0:'۰',
1:'١',
2:'٢',
3:'۳',
4:'۴',
5:'۵',
6:'۶',
7:'۷',
8:'۸',
9:'۹',
.:'۰',
}
return dic.get(number)
and use it like this:
ar_numbers = [enToArNumb(num) for num in numbers]
这篇关于如何将正常数字转换成django中的阿拉伯数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文