python学习-46 时间模块
时间模块
····时间戳
print(time.time())
运行结果:
1564294158.0389376 Process finished with exit code 0
·····结构化时间
print(time.localtime()) # 当地时间
y = time.localtime()
print(y.tm_year)
print(y.tm_wday) print(time.gmtime()) # 世界标准化时间 UTC
运行结果:
time.struct_time(tm_year=2019, tm_mon=7, tm_mday=28, tm_hour=14, tm_min=25, tm_sec=57, tm_wday=6, tm_yday=209, tm_isdst=0)
2019
6
time.struct_time(tm_year=2019, tm_mon=7, tm_mday=28, tm_hour=6, tm_min=25, tm_sec=57, tm_wday=6, tm_yday=209, tm_isdst=0) Process finished with exit code 0
·····结构化时间转换成时间戳
print(time.mktime(time.localtime()))
``````结构化时间转换成字符串时间
print(time.strftime('%Y-%m-%d %X',time.localtime()))
运行结果:
2019-07-28 14:34:58 Process finished with exit code 0
``````字符串时间转换成结构化时间
print(time.strptime('2018:1:1:12:00:00','%Y:%m:%d:%X'))
运行结果:
time.struct_time(tm_year=2018, tm_mon=1, tm_mday=1, tm_hour=12, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1) Process finished with exit code 0
······把结构化时间转换成固定的字符串表达形式
print(time.asctime())
print(time.ctime())
运行结果:
Sun Jul 28 14:43:45 2019
Sun Jul 28 14:43:45 2019 Process finished with exit code 0
····推迟运行
print(time.sleep(1))
ps:
import datetime模块
print(datetime.datetime.now())
python学习-46 时间模块的更多相关文章
- python学习之 - 时间模块
时间模块模块名:time时间模块的转换流程图. UTC:英国格林威治时间.时间戳作用:是用来进行时间计算的.进行加减时间.注意:时间计算是用秒为单位time.process_time():测量处理器运 ...
- python学习总结----时间模块 and 虚拟环境(了解)
time - sleep:休眠指定的秒数(可以是小数) - time:获取时间戳 # 获取时间戳(从1970-01-01 00:00:00到此刻的秒数) t = time.time() print(t ...
- python学习之argparse模块
python学习之argparse模块 一.简介: argparse是python用于解析命令行参数和选项的标准模块,用于代替已经过时的optparse模块.argparse模块的作用是用于解析命令行 ...
- Python学习day19-常用模块之re模块
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- Python学习 Part4:模块
Python学习 Part4:模块 1. 模块是将定义保存在一个文件中的方法,然后在脚本中或解释器的交互实例中使用.模块中的定义可以被导入到其他模块或者main模块. 模块就是一个包含Python定义 ...
- Python学习day18-常用模块之NumPy
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- python学习之random模块
Python中的random模块用于生成随机数.下面介绍一下random模块中最常用的几个函数. random.random random.random()用于生成一个0到1的随机符点数: 0 < ...
- python 学习day5(模块)
一.模块介绍 模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能 ...
- python学习笔记_week5_模块
模块 一.定义: 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能), 本质就是.py结尾的python文件(文件名:test.py,对应模块名:test) 包:用来从逻辑上 ...
随机推荐
- Tkinter 之pack布局
一参数说明 参数 作用 anchor 控制组件在 pack 分配的空间中的位置"n", "ne", "e", "se", ...
- [CMS漏洞]EmpireCMS_V7.5的一次审计【转载】
i春秋作家:Qclover 原文来自:EmpireCMS_V7.5的一次审计 0x01 概述 最近在做审计和WAF规则的编写,在CNVD和CNNVD等漏洞平台寻找各类CMS漏洞研究编写规则时顺便抽空对 ...
- 微信小程序 wxParse插件显示视频
修改wxParse/html2json.js 文件 ,在 html2json(html, bindName) 方法里 var node = { node: 'element', tag: tag, } ...
- 更换镜像加快python pip 安装扩展库的速度
一些镜像源: 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科 ...
- Thingsboard学习之一CentOS安装系统更新
首先安装好系统,查询到系统的IP地址后,使用Putty登入系统 更新系统 yum update 安装git yum install git 动图演示
- Vuex 通俗版教程告诉你Vuex怎么用
写在文前: 最近一直在用vue开发项目,写来写去就是那么些方法,对于简单的项目一些常用的vue方法足以解决,但是涉及到页面状态,权限判断等一些复杂的传值,vuex是必须的.对于vuex也运用一段时间, ...
- android: Context引起的内存泄露问题
错误的使用Context可能会导致内存泄漏,典型的例子就是单例模式时引用不合适的Context. public class SingleInstance { private static Single ...
- [转][PDA]Json.net
文件下载 参考:https://www.cnblogs.com/freezing/p/4125862.html 参考:https://www.cnblogs.com/yunquan/p/7363110 ...
- window 下 某个端口被占用
window 下 某个端口被占用 1. 开始—->运行—->cmd,或者是window+R组合键,调出命令窗口: 2.输入命令:netstat -ano,列出所有端口的情况.在列表中我们观 ...
- JavaScript中三个等号和两个等号的区别(“===”与“==”的区别)
1.===:三个等号我们称为等同符,当等号两边的值为相同类型的时候,直接比较等号两边的值,值相同则返回true,若等号两边的值类型不同时直接返回false. 例:100===“100” //返回f ...