python date time
//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的更多相关文章
- Python date,datetime,time等相关操作总结
date,datetime,time等相关操作总结 by:授客 QQ:1033553122 测试环境: Python版本:Python 3.3.2 代码实践: __author__ = '授客' ...
- Python Date 1–Hello world print
对比学习Python与C str1 = 'hello python 2'# 字符串i = 3.1415926535 print(str1)print("hello python\n" ...
- python date,datetime 和time的区别
这是三个不同类型的数据,例如 2015-11-21 10:51:20: date是日期,表示的是 2015-11-21: datetime是日期时间,表示的是 2015-11-21 10:51:20: ...
- python date
三天前 datetime.datetime.now() - datetime.timedelta(days=3)
- python画柱状图并且输出到html文件
import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltfrom Cstring import StringIO y ...
- Python面试题汇总
原文:http://blog.csdn.net/jerry_1126/article/details/44023949 拿网络上关于Python的面试题汇总了,给出了自认为合理的答案,有些题目不错,可 ...
- python基础学习05(核心编程第二版)部分
# -*- coding: utf-8 -*- # ==================== #File: python #Author: python #Date: 2014 #========== ...
- 树莓派3b添加python时间同步脚本
树莓派没有电池,因此断电后系统时间会停止,直到你开机后又继续计时,所以会造成系统时间和实际时间有很大的误差. 因为项目需要用到本地时间,精度要求不高不想折腾(如果需要高精度,需要安装ntp),所以考虑 ...
- selenium+python—实现自动化测试基本思路
测试是一个贯穿于整个开发过程的连续过程,测试最基本的原理就是比较预期结果是否与实际执行结果相同,如果相同则测试成功,否则测试失败. 为了让单元测试代码能够被测试和维护人员更容易地理解,最好的解决办法是 ...
随机推荐
- A little issue in Mathematical Thought from Ancient to Modern Times, Vol. 3
At P985 of the book, says But there are cuts that are not determined by rational numbers. If we put ...
- Exception 03 : org.hibernate.MappingException: Unknown entity: org.hibernate.cfg.Configuration
异常名称 org.hibernate.MappingException: Unknown entity: org.hibernate.cfg.Configuration 异常详细信息 org.hibe ...
- 新的ipad,用xcode编译报错 dyld_shared_cache_extract_dylibs
删掉 ~/Library/Developer/Xcode/iOS DeviceSupport/ 这个目录下的特定文件夹就行啦. 其实是因为 device is busy 生成文件夹过程中拔掉了设 ...
- oracle查表技巧
查每张表中有多少条记录 SELECT table_name,num_rows FROM user_tables order by num_rows desc; https://www.cnblogs. ...
- LeetCode 349 Intersection of Two Arrays 解题报告
题目要求 Given two arrays, write a function to compute their intersection. 题目分析及思路 给定两个数组,要求得到它们之中共同拥有的元 ...
- ef codefirst 模型字段类型与sqlserver表字段类型对应概要
1.sqlserver中nvarchar(50),对应EF中: [MaxLength(, ErrorMessage = "最大长度为{1}")] public string Nam ...
- 什么是Docker?(一)
Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,它是基于 dotCloud 公司多年云服务技术的一次革新,并于 2013 年 3 月以 ...
- 【Python】脚本运行报错:IndentationError: unindent does not match any outer indentation level
[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not ...
- 将 java 改写成 beanshell 的经验之谈
下面经验仅仅针对 bsh for android 而谈, PC 上 beanshell 无需这样改. public class TimeTest 改写为闭包: TimeTest() 闭包末尾添加语 ...
- RN NetInfo使用
代码: class NetInfoView extends Component { getNetInfo() { //如果是andorid的程序,需要在xml添加获取网络请求权限 NetInfo.fe ...