Python的国际化
生活随笔
收集整理的這篇文章主要介紹了
Python的国际化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python提供了locale模塊來實現國際化,這個模塊提供了到C的本地化功能的一個接口,還提供了一些方法,基于當前的locale來轉換數字和字符串。使用locale模塊來格式化數據#!?/usr/bin/env?python
#coding=utf-8
import?locale
print?"locale",?"=>",?locale.setlocale(locale.LC_ALL,?"")
for?k,?v?in?info.items():
????print?k,?v
#coding=utf-8
import?locale
language,?encoding?=?locale.getdefaultlocale()
print?"language",?language
print?"encoding",?encoding
#coding=utf-8
import?locale
print?"locale",?"=>",?locale.setlocale(locale.LC_ALL,?"")
for?k,?v?in?info.items():
????print?k,?v
?
?
使用locale模塊得到平臺locale?
#!?/usr/bin/env?python#coding=utf-8
import?locale
language,?encoding?=?locale.getdefaultlocale()
print?"language",?language
print?"encoding",?encoding
?
?
?
總結
以上是生活随笔為你收集整理的Python的国际化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ***大赛结果,名企员工缺乏安全意识
- 下一篇: 24h量是什么意思 货币