在Python中操作日期和时间之gmtime()方法的使用

yipeiwu_com6年前Python基础

 gmtime()方法转换历元到一struct_time以UTC其中dst的标志值始终为0以秒表示时间。如果不设置秒时或None,返回的时间为当前time()。
语法

以下是gmtime()方法的语法:

time.gmtime([ sec ])

参数

  •     sec -- 这是秒数转换成结构struct_time来表示。

返回值

此方法不返回任何值。
例子

下面的例子显示了gmtime()方法的使用。

#!/usr/bin/python
import time

print "time.gmtime() : %s" % time.gmtime()

当我们运行上面的程序,它会产生以下结果:

time.gmtime() : (2009, 2, 17, 17, 3, 38, 1, 48, 0)

相关文章

django获取from表单multiple-select的value和id的方法

如下所示: <select id="host_list" name="host_list" multiple> {% for op in host_list %}...

pytorch 自定义参数不更新方式

nn.Module中定义参数:不需要加cuda,可以求导,反向传播 class BiFPN(nn.Module): def __init__(self, fpn_sizes):...

在python Numpy中求向量和矩阵的范数实例

在python Numpy中求向量和矩阵的范数实例

np.linalg.norm(求范数):linalg=linear(线性)+algebra(代数),norm则表示范数。 函数参数 x_norm=np.linalg.norm(x,...

浅析python3中的os.path.dirname(__file__)的使用

Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑...

python监控nginx端口和进程状态

本文实例为大家分享了python监控nginx端口和进程状态的具体代码,供大家参考,具体内容如下 #!/usr/local/bin/python # coding:utf-8 imp...