python日期
来源:互联网 发布:路老膏方 诈骗让网络 编辑:程序博客网 时间:2024/05/23 13:37
转换日期格式是一个常见的例行琐事。
Python有一个time and calendar模组可以帮忙。
获取当前时间Unix time
从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数。
打开cmd查看现在的Unix time。
import time; # This is required to include time module.ticks = time.time()print ticks #1442477018.57
1970年之前的日期就无法以此表示了。太遥远的日期也不行,UNIX和Windows只支持到2038年某日。
获取当前时间-年月日
import time;localtime = time.localtime(time.time()) #time.time()是当前时间的时间戳,也可以直接输入某个时间戳1443688070print "Local current time :", localtime
输出
Local current time : time.struct_time(tm_year=2013, tm_mon=7, tm_mday=17, tm_hour=21, tm_min=26, tm_sec=3, tm_wday=2, tm_yday=198, tm_isdst=0)
unix time转当前时间
time.localtime(某个unix time)
格式化的时间
最简单的获取可读的时间模式的函数是asctime():
import time;localtime = time.asctime( time.localtime(time.time()) )print "Local current time :", localtime#输出:Local current time : Tue Jan 13 10:17:09 2009
datetime
0 0
- python日期
- python-日期
- python -- 日期
- Python日期操作笔记
- python的日期处理
- Python日期操作笔记
- Python格式化日期时间
- Python 日期时间格式化
- Python日期操作笔记
- python日期操作
- Python学习---日期操作
- Python日期处理
- python 日期加減
- Python日期操作
- python日期操作
- Python日期操作
- Python日期操作
- python 时间和日期
- LINQ Take和Skip
- scrollview和listview 冲突 动态定listview高度
- 重新学习C# 之 数据类型(一)
- 趣谈i++与++i
- JavaWeb中Dao层的接口和基本功能简单抽取技巧
- python日期
- iOS自定义相机
- CentOS 7上启动Oracle 11.2.0.3
- c++primer plus 编程练习题2
- iOS 打包ipa的方法
- ASI同步(AFN做不到的东西)
- 【微信链接3种方式】
- Java集合总体框架
- 局部变量、全局变量和静态变量的关系。