python3中time模块与datetime模块的简单用法
__author__ = "JentZhang" import time # Timestamp 时间戳
print("Timestamp 时间戳:")
print(time.time())
print("#".center(50,"#")) # Structime 结构化时间
print("Structime 结构化时间:")
print(time.gmtime())
print(time.localtime())
print(time.struct_time)
print("#".center(50,"#")) # 格式化时间为能看得懂的格式
print("格式化时间为能看得懂的格式:")
print(time.strftime("%Y-%m-%d %X", time.localtime()))
print(time.strftime("%Y-%m-%d %X"))
print(time.strftime("%Y-%m-%d %H:%M:%S"))
print("#".center(50,"#")) import datetime # 计算3天前的当前时间
print("计算3天前的当前时间:")
time_str = (datetime.datetime.now() + datetime.timedelta(-3))
print(type(time_str))
print(time_str.strftime("%Y-%m-%d %H:%M:%S"))
# print(datetime.date)

python3中time模块与datetime模块的简单用法的更多相关文章
- python中time模块和datetime模块
time模块和datetime模块 时间分为三种模式(time 模块) 时间戳 (time.time()) 格式化字符串 (time.strftime(%Y-%m-%d %H:%M:%S %p)) ...
- Time模块和datetime模块
Time模块和datetime模块 一. 调用 import time #调用time模块 二.使用方法 1.time.time 拿到时间戳.以Linux诞生年份1970年开始计算到程序执 ...
- Python之路(第十六篇)xml模块、datetime模块
一.xml模块 xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但json使用起来更简单, xml比较早,早期许多软件都是用xml,至今很多传统公司如金融行业的很多系统的接口还主要 ...
- (转)python time模块和datetime模块详解
python time模块和datetime模块详解 原文:http://www.cnblogs.com/tkqasn/p/6001134.html 一.time模块 time模块中时间表现的格式主要 ...
- python time模块 sys模块 collections模块 random模块 os模块 序列化 datetime模块
一 collections模块 collections模块在内置的数据类型,比如:int.str.list.dict等基础之上额外提供了几种数据类型. 参考博客 http://www.pythoner ...
- python3 time模块与datetime模块
time模块 在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素.由于Python的time模块实现主要调用C库,所以各个平 ...
- 详解:Python2中的urllib、urllib2与Python3中的urllib以及第三方模块requests
在python2中,urllib和urllib2都是接受URL请求的相关模块,但是提供了不同的功能.两个最显著的不同如下: 1.urllib2可以接受一个Request类的实例来设置URL请求的hea ...
- python time模块和datetime模块详解
一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...
- python time模块和datetime模块
一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...
- day21 Pythonpython time模块和datetime模块详解
一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...
随机推荐
- R语言读入数据库的中英名词互译测试并计分脚本(考试用)
1. 分子生物学中英文.csv,输入文件,两列,以tab键分隔的txt文本,没有列名 2. 错误的名解.csv, 如果在测试中拼写错误,会写出到这个文件,可用这个容易犯错的名词进行新的测试 3. 注意 ...
- Expedition---POJ - 2431
A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poo ...
- Filter(过滤器)
一.Filter简介 Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态 ...
- Python练手例子(16)
91.时间函数举例1. #!/usr/bin/python #coding=utf-8 import time if __name__ == '__main__': #time.time()返回当前的 ...
- 解决微信小程序video属性controls失效问题
<view class="VideoBox"> <video class='myVideo' id="myVideo01" src=" ...
- JS实现数组去重方法大总结
js数组根据对象中的元素去重: var arr2 = [ { name: "name1", num: "1" }, { name: "name2&qu ...
- [WEB]绕过安全狗与360PHP一句话的编写
00x01安全狗的确是让人很头痛,尤其是在上传一句话或者写入一句话的时候,会被安全狗拦截从而拿不下shell.当然,安全狗是最简单的一款waf,很容易就进行一个绕过.00x02对于绕过安全狗跟360, ...
- 流媒体协议(一):HLS 协议
一.HLS 概述 HLS 全称是 HTTP Live Streaming,是一个由 Apple 公司提出的基于 HTTP 的媒体流传输协议,用于实时音视频流的传输.目前HLS协议被广泛的应用于视频点播 ...
- [Swift]LeetCode80. 删除排序数组中的重复项 II | Remove Duplicates from Sorted Array II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- [Swift]LeetCode433. 最小基因变化 | Minimum Genetic Mutation
A gene string can be represented by an 8-character long string, with choices from "A", &qu ...