×
Python3 教程Python3 基础语法Python3 基本数据类型Python3 解释器Python3 注释Python3 运算符Python3 数字(Number)Python3 字符串Python3 列表Python3 元组Python3 字典Python3 编程第一步Python3 条件控制Python3 循环语句Python3 迭代器与生成器Python3 函数Python3 数据结构Python3 模块Python3 输入和输出Python3 FilePython3 OSPython3 错误和异常Python3 面向对象Python3 标准库概览Python3 实例

Python3 高级教程

Python3 正则表达式Python3 CGI编程Python3 MySQLPython3 网络编程Python3 SMTP发送邮件Python3 多线程Python3 XML解析Python3 JSONPython3 日期和时间Python3 内置函数Python MongoDBPython uWSGI 安装配置

Python3 time mktime()方法


Python3 日期和时间Python3 日期和时间


描述

Python time mktime() 函数执行与gmtime(), localtime()相反的操作,它接收struct_time对象作为参数,返回用秒数来表示时间的浮点数。

如果输入的值不是一个合法的时间,将触发 OverflowError 或 ValueError。

语法

mktime()方法语法:

time.mktime(t)

参数

  • t -- 结构化的时间或者完整的9位元组元素。

返回值

返回用秒数来表示时间的浮点数。

实例

以下实例展示了 mktime() 函数的使用方法:

#!/usr/bin/python3
import time

t = (2016, 2, 17, 17, 3, 38, 1, 48, 0)
secs = time.mktime( t )
print ("time.mktime(t) : %f" %  secs)
print ("asctime(localtime(secs)): %s" % time.asctime(time.localtime(secs)))

以上实例输出结果为:

time.mktime(t) : 1455699818.000000
asctime(localtime(secs)): Wed Feb 17 17:03:38 2016

Python3 日期和时间Python3 日期和时间


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)