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—实现自动化测试基本思路
测试是一个贯穿于整个开发过程的连续过程,测试最基本的原理就是比较预期结果是否与实际执行结果相同,如果相同则测试成功,否则测试失败. 为了让单元测试代码能够被测试和维护人员更容易地理解,最好的解决办法是 ...
随机推荐
- c语言中的左移和右移
先说左移,左移就是把一个数的所有位都向左移动若干位,在C中用<<运算符.例如: int i = 1;i = i << 2; //把i里的值左移2位 也就是说,1的2进制是00 ...
- svn异常:subversion.javahl.ClientException
使用svn时出现异常: INFO [org.netbeans.modules.subversion]: org.apache.subversion.javahl.ClientException: Pr ...
- scokte tcp/ip
import scoket# 服务端 server = socket.socket() ip_port = ("127.0.0.1",8001) server.bind(ip_po ...
- 安装指定版本的nodejs
node有一个模块n,是专门用来管理node.js的版本的. 1.安装n模块: npm install -g n 2.升级node.js到最新稳定版 n stable 3.安装指定版本: n v6.1 ...
- xcode工程编译错误:error: Couldn’t materialize
错误信息: error: Couldn't materialize: couldn't get the value of variable amount: variable not available ...
- AndroidsStudio_找Bug
新版本不再提供Android Monitor,但在Logcat中可以找到运行日志,但在Regex中要勾选Show only... 另外设置一个控件记得加id.
- java Scanner和Random的Demo
import java.util.Scanner;//导入包 import java.util.Random; public class ScannerDemo{ public static void ...
- 【PyQt5-Qt Designer】窗口操作
1.窗口最上栏最大化 最小化 关闭按钮显示 #设置最小化与最大化按钮 self.setWindowFlags(QtCore.Qt.Window) 将其添加到Ui_*** 布局代码中即可 2.窗口知识 ...
- 如何让html中的td文字只显示部分
以下笔记有待测试 ———————————————————— <table style="table-layout:fixed"> <tr> <td s ...
- oracle中not in 和 in 的替代写法
-- not in 的替代写法select col from table1 where col not in(select col from table2); select col,table2.co ...