在Python中获取系统的时区信息? [英] Get time zone information of the system in Python?

查看:87
本文介绍了在Python中获取系统的时区信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Python获取系统的默认时区(PST)。最好的方法是什么?我想避免另一个过程。

解决方案

查看Python 时间模块。

 从时间导入gmtime,strftime 
打印strftime(%z,gmtime())

太平洋标准时间


I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.

解决方案

Check out the Python Time Module.

from time import gmtime, strftime
print strftime("%z", gmtime())

Pacific Standard Time

这篇关于在Python中获取系统的时区信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆