//test.py

import time

ticks = time.time()
print ticks
localtime = time.localtime(time.time())
print localtime
print time.asctime(localtime)

print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
t = time.strftime('%a %b %d %H:%M:%S %Y', time.localtime())
print t
print time.mktime(time.strptime(t, '%a %b %d %H:%M:%S %Y'))
print 'altzone:',time.altzone
t1 = time.clock()
print 't1', t1
#time.sleep(1)
t2 = time.clock()
print 't2', t2
print 'ctime',time.ctime()
print 'gmtime', time.gmtime()
print 'localtime', time.localtime()
print 'timezone',time.timezone
print time.tzname

import calendar

cal = calendar.month(2017, 11)
print cal
print calendar.calendar(2017, w=2,l=1,c=6)
print calendar.firstweekday()
print calendar.isleap(2017)
print calendar.leapdays(2017, 2022)
print calendar.month(2017,11, w=2,l=1)
print calendar.monthcalendar(2017, 11)
print calendar.monthrange(2017, 11)
calendar.setfirstweekday(6)
print 'firstweekday',calendar.firstweekday()
print calendar.timegm(time.localtime())
print calendar.weekday(2017,11,6)

//result

# python test.py

1509959417.55
time.struct_time(tm_year=2017, tm_mon=11, tm_mday=6, tm_hour=1, tm_min=10, tm_sec=17, tm_wday=0, tm_yday=310, tm_isdst=0)
Mon Nov 6 01:10:17 2017
2017-11-06 01:10:17
Mon Nov 06 01:10:17 2017
1509959417.0
altzone: 25200
t1 0.010813
t2 0.010816
ctime Mon Nov 6 01:10:17 2017
gmtime time.struct_time(tm_year=2017, tm_mon=11, tm_mday=6, tm_hour=9, tm_min=10, tm_sec=17, tm_wday=0, tm_yday=310, tm_isdst=0)
localtime time.struct_time(tm_year=2017, tm_mon=11, tm_mday=6, tm_hour=1, tm_min=10, tm_sec=17, tm_wday=0, tm_yday=310, tm_isdst=0)
timezone 28800
('PST', 'PDT')

0
False
1

[[0, 0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 0, 0, 0]]
(2, 30)
firstweekday 6
1509930617
0

python date time的更多相关文章

  1. Python date,datetime,time等相关操作总结

    date,datetime,time等相关操作总结   by:授客 QQ:1033553122 测试环境: Python版本:Python 3.3.2 代码实践: __author__ = '授客' ...

  2. Python Date 1–Hello world print

    对比学习Python与C str1 = 'hello python 2'# 字符串i = 3.1415926535 print(str1)print("hello python\n" ...

  3. python date,datetime 和time的区别

    这是三个不同类型的数据,例如 2015-11-21 10:51:20: date是日期,表示的是 2015-11-21: datetime是日期时间,表示的是 2015-11-21 10:51:20: ...

  4. python date

    三天前 datetime.datetime.now() - datetime.timedelta(days=3)

  5. python画柱状图并且输出到html文件

    import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltfrom Cstring import StringIO y ...

  6. Python面试题汇总

    原文:http://blog.csdn.net/jerry_1126/article/details/44023949 拿网络上关于Python的面试题汇总了,给出了自认为合理的答案,有些题目不错,可 ...

  7. python基础学习05(核心编程第二版)部分

    # -*- coding: utf-8 -*- # ==================== #File: python #Author: python #Date: 2014 #========== ...

  8. 树莓派3b添加python时间同步脚本

    树莓派没有电池,因此断电后系统时间会停止,直到你开机后又继续计时,所以会造成系统时间和实际时间有很大的误差. 因为项目需要用到本地时间,精度要求不高不想折腾(如果需要高精度,需要安装ntp),所以考虑 ...

  9. selenium+python—实现自动化测试基本思路

    测试是一个贯穿于整个开发过程的连续过程,测试最基本的原理就是比较预期结果是否与实际执行结果相同,如果相同则测试成功,否则测试失败. 为了让单元测试代码能够被测试和维护人员更容易地理解,最好的解决办法是 ...

随机推荐

  1. c++ assert() 使用方法

    assert宏的原型定义在<assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include <assert.h> void assert( i ...

  2. [development][C] C语言标准

    GUN C的标准文档: 也就是glibc https://www.gnu.org/software/libc/ http://man7.org/linux/man-pages/dir_section_ ...

  3. [未解决:快速滑动collectionveiw请求数据崩溃]:unable to allocate 6553600 bytes for bitmap data

    崩溃:unable to allocate 6553600 bytes for bitmap data

  4. 2018/04/25 基于 编译安装的 PHP7 安装 swoole 扩展

    在上一篇文章我们知道了如何去编译安装一个自己需要的 PHP 版本. 2018/04/25 PHP7的编译安装 这里还没有完,我们还需要安装我们的扩展,才算完成今天的任务. -- 下载扩展 还是官网下载 ...

  5. kubernetes的apiserver

    1. API Server简介 k8s API Server提供了k8s各类资源对象(pod,RC,Service等)的增删改查及watch等HTTP Rest接口,是整个系统的数据总线和数据中心. ...

  6. canvas将图片转成base64格式 以及 验证图片是否透明

    logoImgUpload:function(file) { let self = this; self.formatUpload(file); let reader = new FileReader ...

  7. Git 常用命令和统计代码量

    摘要 分享Git日常操作中常用的命令,分享如何统计在项目中贡献的代码量. 下面列出Git bash常用命令. 1. git clone **(项目地址) 克隆一个git项目到本地,将git项目拉取到本 ...

  8. 深入了解HBASE架构(转)

    dd by zhj: 最近的工作需要跟HBase打交道,所以花时间把<HBase权威指南>粗略看了一遍,感觉不过瘾,又从网上找了几篇经典文章. 下面这篇就是很经典的文章,对HBase的架构 ...

  9. winform接收全局的快捷键

    public class NativeWIN32 { public NativeWIN32() { } /* ------- using WIN32 Windows API in a C# appli ...

  10. cuda9.0编译caffe报错nvcc fatal : Unsupported gpu architecture 'compute_70'

    Tesla V100 cuda9.0 caffe编译的时候报上述错误,修改方法: CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \ #-genco ...