Tro*_*ane 5 python timezone localization internationalization pytz
有没有一种方法可以用另一种语言检索时区名称?
在Python中,如果我做这样的事情:
for tz in pytz.common_timezones_set :
print tz
Run Code Online (Sandbox Code Playgroud)
结果是用英语写的,但如果我想用西班牙语或阿拉伯语怎么样呢?
你可以使用babel 包
import pytz
from babel.dates import get_timezone_location
for tz in pytz.common_timezones_set:
print(get_timezone_location(tz, locale='es'))
Run Code Online (Sandbox Code Playgroud)