time-时间模块
# time模块
import time
# 时间戳
res = time.time() # ***
print(res, type(res)) # time.sleep(1) # ***
# print(123) # 自定义延迟
# old_time = time.time()
# while time.time() - old_time < 3:
# pass
# print(123) # res = time.localtime()
# print(res.tm_year, type(res)) # ***
# res = time.strftime('%Y-%m-%d %H:%M:%S')
# print(res, type(res)) # time_tuple = (2010, 4, 27, 18, 10, 59, 0, 0, 0)
# res = time.strftime('%Y-%m-%d %H:%M:%S', time_tuple)
# res = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1556359559))
# print(res) # print(time.gmtime()) # import calendar
# # 判断闰年
# print(calendar.isleap(2000))
# # 查看某年某月日历
# print(calendar.month(2008, 8))
# # 查看某年某月起始星期与当月天数
# print(calendar.monthrange(2019, 4))
# # 查看某年某月某日是星期几
# print(calendar.weekday(2019, 4, 1)) import datetime
# 当前时间 ***
res = datetime.datetime.now()
print(res, type(res)) # 可以完成时间的运算
print(datetime.datetime.now() + datetime.timedelta(hours=1)) time_obj = datetime.datetime.now()
print(time_obj) # 修改时间
new_time = time_obj.replace(year=2000, day=1)
print(new_time) # 格式化时间戳: 2019-04-27
print(datetime.date.fromtimestamp(1556359520))
time-时间模块的更多相关文章
- python时间模块-time和datetime
时间模块 python 中时间表示方法有:时间戳,即从1975年1月1日00:00:00到现在的秒数:格式化后的时间字符串:时间struct_time 元组. struct_time元组中元素主要包括 ...
- 浅谈Python时间模块
浅谈Python时间模块 今天简单总结了一下Python处理时间和日期方面的模块,主要就是datetime.time.calendar三个模块的使用.希望这篇文章对于学习Python的朋友们有所帮助 ...
- python_way ,day2 字符串,列表,字典,时间模块
python_way ,day2 字符串,列表,字典,自学时间模块 1.input: 2.0 3.0 区别 2.0中 如果要要用户交互输入字符串: name=raw_input() 如果 name=i ...
- python的时间模块
python有两个重要的时间模块,分别是time和datetime 先看time模块 表示时间的几种方法: 1)时间元组:time.struct_time(tm_year=2016, tm_mon ...
- s14 第5天 时间模块 随机模块 String模块 shutil模块(文件操作) 文件压缩(zipfile和tarfile)shelve模块 XML模块 ConfigParser配置文件操作模块 hashlib散列模块 Subprocess模块(调用shell) logging模块 正则表达式模块 r字符串和转译
时间模块 time datatime time.clock(2.7) time.process_time(3.3) 测量处理器运算时间,不包括sleep时间 time.altzone 返回与UTC时间 ...
- 第三十二节,datetime时间模块
首先要引入import datetime时间模块 datetime.date.today()模块函数 功能:输出系统年月日输出格式 2016-01-26[无参] 使用方法:datetime.date. ...
- 【python标准库模块一】时间模块time学习
本文介绍python的标准库模块time的常见用法 时间模块time 导入时间模块 import time 得到时间戳,这是统计从1970年1月1日0点0分到现在经过了多少秒,一般用于加减法一起用,比 ...
- Python—day17时间模块、系统模块、递推遍历、序列化
一.time'''时间戳(timestamp):time.time()延迟线程的运行:time.sleep(secs)(指定时间戳下的)当前时区时间:time.localtime([secs])(指定 ...
- 【转载】Python日期时间模块datetime详解与Python 日期时间的比较,计算实例代码
本文转载自脚本之家,源网址为:https://www.jb51.net/article/147429.htm 一.Python中日期时间模块datetime介绍 (一).datetime模块中包含如下 ...
- python基础 ---time,datetime,collections)--时间模块&collections 模块
python中的time和datetime模块是时间方面的模块 time模块中时间表现的格式主要有三种: 1.timestamp:时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算 ...
随机推荐
- vue 预渲染遇到的坑
前言: 最近公司项目需要增加seo搜索引擎优化,到网上找了下资料,有预渲染和服务端渲染两种方式,考虑到只需要渲染首页所以我选择了先启用比较简单的预渲染方式来做seo! 步骤: 1.安装 prerend ...
- 使用exceljs时报错:no such file or directory
最近使用exceljs生成excel并保存时,总是失败 await workbook.xlsx.writeFile(tep) .then(function () { context.result = ...
- php载入脚本的几种方式对比
require require_once include include_once 共同点: 都可以在当前 PHP 脚本文件执行时载入另外一个 PHP 脚本文件. require 和 include ...
- Spring 数据库读写分离
读写分离常见有俩种方式 1 第一种方式比较常用就是定义2个数据库连接,一个是Master,另一个是Slave.更新数据时我们取Master,查询数据时取Slave.太过简单不做介绍. 2 第二种方数据 ...
- sersync自动化同步部署
目录 0. 前提: 1. 部署rsync server服务 1.1 配置rsync配置文件 1.2 rsync配置文件说明: 1.3 创建密码文件修改权限600 1.4 创建提示文件(可有可无) 1. ...
- GC参考手册 —— GC 算法(基础篇)
本章简要介绍GC的基本原理和相关技术, 下一章节再详细讲解GC算法的具体实现.各种垃圾收集器的实现细节虽然并不相同,但总体而言,垃圾收集器都专注于两件事情: 查找所有存活对象 抛弃其他的部分,即死对象 ...
- 简单实现springmvc框架(servlet+自定义注解)
个人水平比较菜,没有这么高的实力简单实现springmvc框架,我是看了一个老哥的博客,这老哥才是大神! 原文链接:https://www.cnblogs.com/xdp-gacl/p/4101727 ...
- [转]How to Download and Setup Blue Prism
本文转自:https://www.hopetutors.com/blog/uncategorized/how-to-download-and-setup-blue-prism/ The Downloa ...
- 【Oracle学习笔记】定时任务(dbms_job)
一.概述 Oralce中的任务有2种:Job和Dbms_job,两者的区别有: 1. jobs是oracle数据库的对象, dbms_jobs只是jobs对象的一个实例, 就像对于tables, e ...
- [.NET] 使用 Senparc.Weixin 接入微信公众号开发:简单实现自动回复
使用 Senparc.Weixin 接入微信公众号开发:简单实现自动回复 目录 一.前提 二.基本配置信息简析 三.配置服务器地址(URL) 四.请求处理 一.前提 先申请微信公众号的授权,找到或配置 ...