//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. MySQL使用mysqldump备份及还原

    MySQL可以使用mysqldump进行数据的逻辑备份,配合开启bin log日志可以实现数据的全量恢复及增量恢复 MySQL版本查看 修改配置文件记录bin log日志 [mysqld] #bin ...

  2. Zabbix监控MySQL免密码设置

    zabbix自带MySQL监控模板,配置文件在/etc/zabbix/zabbix_agentd.d userparameter_mysql.conf 如果MySQL不使用密码可以直接使用这个监控模板 ...

  3. [No000011B]为什么有些程序员悄无声息渡过35岁中年危机?

    今天分享是一些已经渡过中年危机的前辈们,看看从他们身上,是如何优雅的过渡的.如果想一直在程序这条路上走下去,建议读完.文章略长. 人物一:陈睿,前百度研发经理,携程定制旅游CTO 从程序员到架构师到管 ...

  4. centos 安装docker-compose

    #查看docker compose版本 docker-compose version #查看pip版本 pip -v #上一条语句没有显示版本信息则运行下面语句安装 python-pip yum -y ...

  5. [about remote controller]--mstsc-teamviewer-vnc,nomachine

    https://www.jianshu.com/p/c80db368ed8a https://www.nomachine.com/download Ubuntu安装VNC,VNC却无法随系统启动,遂换 ...

  6. [tcpreplay] tcpreplay高级用法--使用tcpreplay-edit进行循环动态发包

    tcpreplay-edit提供了可对包进行修改的高级用法: --unique-ip Modify IP addresses each loop iteration to generate uniqu ...

  7. delphi string.split 按照任意字符串分割语句

    delphi string.split 按照任意字符串分割语句 1.就是把一个指定的字符串用指定的分割符号分割成多个子串,放入一个 TStringList 中 function ExtractStri ...

  8. es6学习笔记入门总结

    1.let const block 作用域 let 代替var 来声明块级作用域,没有变量提升,只在块内有作用 const 可以声明一个常量,类似于指针,指向某一个引用,这个常量并非一成不变的,但是不 ...

  9. 优云软件又双叒通过CMMI ML3评估 , 研发和质量管理水平创新高

    2017年第三季度,SEI授权的主任评估师对优云软件研发中心进行了CMMI软件能力成熟度模型评估,优云软件顺利通过复评. 这是继2011年12月优云软件首次通过CMMI ML3级的评估认证以来,第二次 ...

  10. 实践-通过matlab操作sqlite数据库

    1.下载sqlite-jdbc连接数据库地址 https://bitbucket.org/xerial/sqlite-jdbc/downloads/ 2.将该jar包的绝对路径写入matlab的cla ...