# 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-时间模块的更多相关文章

  1. python时间模块-time和datetime

    时间模块 python 中时间表示方法有:时间戳,即从1975年1月1日00:00:00到现在的秒数:格式化后的时间字符串:时间struct_time 元组. struct_time元组中元素主要包括 ...

  2. 浅谈Python时间模块

    浅谈Python时间模块 今天简单总结了一下Python处理时间和日期方面的模块,主要就是datetime.time.calendar三个模块的使用.希望这篇文章对于学习Python的朋友们有所帮助 ...

  3. python_way ,day2 字符串,列表,字典,时间模块

    python_way ,day2 字符串,列表,字典,自学时间模块 1.input: 2.0 3.0 区别 2.0中 如果要要用户交互输入字符串: name=raw_input() 如果 name=i ...

  4. python的时间模块

    python有两个重要的时间模块,分别是time和datetime 先看time模块 表示时间的几种方法: 1)时间元组:time.struct_time(tm_year=2016,   tm_mon ...

  5. 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时间 ...

  6. 第三十二节,datetime时间模块

    首先要引入import datetime时间模块 datetime.date.today()模块函数 功能:输出系统年月日输出格式 2016-01-26[无参] 使用方法:datetime.date. ...

  7. 【python标准库模块一】时间模块time学习

    本文介绍python的标准库模块time的常见用法 时间模块time 导入时间模块 import time 得到时间戳,这是统计从1970年1月1日0点0分到现在经过了多少秒,一般用于加减法一起用,比 ...

  8. Python—day17时间模块、系统模块、递推遍历、序列化

    一.time'''时间戳(timestamp):time.time()延迟线程的运行:time.sleep(secs)(指定时间戳下的)当前时区时间:time.localtime([secs])(指定 ...

  9. 【转载】Python日期时间模块datetime详解与Python 日期时间的比较,计算实例代码

    本文转载自脚本之家,源网址为:https://www.jb51.net/article/147429.htm 一.Python中日期时间模块datetime介绍 (一).datetime模块中包含如下 ...

  10. python基础 ---time,datetime,collections)--时间模块&collections 模块

    python中的time和datetime模块是时间方面的模块 time模块中时间表现的格式主要有三种: 1.timestamp:时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算 ...

随机推荐

  1. GitHub开源:升讯威 SQLite 增强组件 Sheng.SQLite.Plus

    Github:https://github.com/iccb1013/Sheng.SQLite.Plus Sheng.SQLite.Plus 是一个对直接使用 ADO.NET 方式操作 SQLite ...

  2. 和逛微博、刷朋友圈一样玩转 GitHub

    自打毕业之后,可以说每天打开 Github 或Email 看有没有 watch 项目的消息或者自己项目的 issue,然后在Explore 看看社区内项目的走势,紧接着开始写代码搬砖的工作,偶尔也会关 ...

  3. 3.Flask-SQLAlchemy

    (1)安装 pip install flask_sqlalchemy (2)数据库连接 from flask import Flask # 1.导入 from flask_sqlalchemy imp ...

  4. Postman Mock Server

    为了不影响前端开发的进度,一般后端都是先定数据结构,然后写个假接口让前端调用,这样前端就不必等着后端接口开发完成以后再开始了.届时,前后端以及UI和测试就可以并行,待双方都把各自的逻辑写好了,便可以联 ...

  5. springboot~zuul实现网关

    网关在微服务里的角色 在微服务架构体系里,网关是非常重要的一个环节,它主要实现了一些功能的统一处理,包括了: 统一授权 统一异常处理 路由导向 跨域处理 限流 实践一下 1 添加依赖 dependen ...

  6. [Nodejs] node写个hello,world

    http 模块 与 hello world hello world let http = require("http"); http .createServer((request, ...

  7. js对象数组(JSON) 根据某个共同字段 分组

    首先判断 var arr = [ {"id":"1001","name":"值1","value": ...

  8. LINQ之道

    提到LINQ首先我们要了解什么是委托:委托是一种引用方法的类型.一旦为委托分配了方法,委托将与该方法具有完全相同的行为.也就是说当你委托给一个人办一件事的时候,他就拥有这个能力去实现这件事,同样委托也 ...

  9. 基础知识:语言、编程、计算机组成、cpu、存储器

    2019年3月18日一.    语言:一种事物与另外一种事物沟通的介质.              编程语言:程序员与计算机沟通的介质.    编程:把要让计算机做的事用一种编程语言表达出来.    ...

  10. Java开发笔记(序)章节目录

    现将本博客的Java学习文章整理成以下笔记目录,方便查阅. 第一章 初识JavaJava开发笔记(一)第一个Java程序Java开发笔记(二)Java工程的帝国区划Java开发笔记(三)Java帝国的 ...