#!/usr/bin/env python
# -*- coding:utf-8 -*-
import time
import datetime,shutil,os
import calendar print(time.time())
print(time.localtime(time.time())) print(time.asctime(time.localtime(time.time()))) # 格式化成2016-03-20 11:45:39形式
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) # 格式化成Sat Mar 28 22:24:24 2016形式
print(time.strftime("%a %b %d %H:%M:%S %Y", time.localtime())) # 将格式字符串转换为时间戳
a = "Sat Mar 28 22:24:24 2016"
print(time.mktime(time.strptime(a, "%a %b %d %H:%M:%S %Y"))) len=calendar.firstweekday() lena=calendar.month(2018,3,w=2,l=1)
lena=calendar.calendar(2018,w=2,l=1,c=6)
print(lena) len=calendar.leapdays(2006,2018)
len=calendar.isleap(2018)
print(len) lenb=calendar.weekday(2018,3,28)
print(lenb) # calendar.timegm()
print(time.gmtime())
year=2018
month=4
day=10
lenc=calendar.monthrange(year,month)
lenc=calendar.monthcalendar(year,month)
lenc=calendar.weekday(year,month,day)
lenc=calendar.calendar(year, w=1, l=1, c=3, m=3)
lenc=calendar.month(year,month,w=2,l=1)
lenc=calendar.timegm((2017, 7, 24, 11, 19, 0, 0, 0, 0))
lend=time.gmtime(lenc) lenf=time.mktime(time.strptime(lend,'%Y-%m-%d %H:%M:%S'))
# print(lend)
print(lenf)
print(lenc) def procedure():
time.sleep(2.5) t0=time.clock()
procedure()
print(time.clock()-t0) t1=time.time()
procedure()
print(time.time()-t1) lena=time.altzone
print(lena) t=time.localtime()
lena=time.asctime(t)
lena=time.ctime() print(lena) os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
time.tzset()
print(time.strftime('%X %x %Z')) print(dir())
print(help(time)) lena01,lena02=time.timezone,time.tzname
print(lena01,lena02) # 返回格林威治西部的夏令时地区的偏移秒数
lena1=time.altzone
print(lena1) # 接收时间元组,返回字符串表示可读的当地日期时间
lena2=time.asctime(time.localtime())
print(lena2) # 以浮点方式计算的描述返回当前CPU的时间
lena3=time.clock()
print(lena3) # 接收时间元组,返回时间戳
lena4=time.mktime(time.localtime())
print(lena4) # 接收时间元组,返回字符串表示的当地日期时间
lena5=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
print(lena5) # 接收字符串表示的日期时间,返回时间元组
lena6=time.strptime(lena5,'%Y-%m-%d %H:%M:%S')
print(lena6) # 接收时间戳,返回当地时间时间元组
lena7=time.localtime(time.time())
print(lena7) # 接收时间戳,返回格林威治天文时间时间元组
lena8=time.gmtime(time.time())
print(lena8) # 返回当前时间戳
lena9=time.time()
print(lena9)

python3基础14(有关日期的使用2)的更多相关文章

  1. Python3基础知识之日期时间与字符的转换

    问题:“猿类”们都知道,编程中都会涉及到日期.时间类型与字符串类型的转换.不同场景,需要将字符串格式转换为日期类型:也需要将日期类型转换为字符串格式. 目标: 学习和积累python中time和dat ...

  2. JAVA 基础编程练习题14 【程序 14 求日期】

    14 [程序 14 求日期] 题目:输入某年某月某日,判断这一天是这一年的第几天? 程序分析:以 3 月 5 日为例,应该先把前两个月的加起来,然后再加上 5 天即本年的第几天,特殊情况, 闰年且输入 ...

  3. [.net 面向对象编程基础] (14) 重构

    [.net 面向对象编程基础] (14) 重构 通过面向对象三大特性:封装.继承.多态的学习,可以说我们已经掌握了面向对象的核心.接下来的学习就是如何让我们的代码更优雅.更高效.更易读.更易维护.当然 ...

  4. python3基础视频教程

    随着目前Python行业的薪资水平越来越高,很多人想加入该行业拿高薪.有没有想通过视频教程入门的同学们?这份Python教程全集等你来学习啦! python3基础视频教程:http://pan.bai ...

  5. Python3基础-特别函数(map filter partial reduces sorted)实例学习

    1. 装饰器 关于Python装饰器的讲解,网上一搜有很多资料,有些资料讲的很详细.因此,我不再详述,我会给出一些连接,帮助理解. 探究functools模块wraps装饰器的用途 案例1 impor ...

  6. 十四. Python基础(14)--递归

    十四. Python基础(14)--递归 1 ● 递归(recursion) 概念: recursive functions-functions that call themselves either ...

  7. 2. Python3 基础入门

    Python3 基础入门 编码 在python3中,默认情况下以UTF-8编码.所有字符串都是 unicode 字符串,当然也可以指定不同编码.体验过2.x版本的编码问题,才知道什么叫难受. # -* ...

  8. python002 Python3 基础语法

    python002 Python3 基础语法 编码默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串. 当然你也可以为源码文件指定不同的编码: # -* ...

  9. Python3基础(十二) 学习总结·附PDF

    Python是一门强大的解释型.面向对象的高级程序设计语言,它优雅.简单.可移植.易扩展,可用于桌面应用.系统编程.数据库编程.网络编程.web开发.图像处理.人工智能.数学应用.文本处理等等. 在学 ...

随机推荐

  1. 模拟使用zookeeper实现master选举

    1.模拟选举机器类 package com.karat.cn.zookeeperAchieveLock.zkclient; import java.io.Serializable; /** * 选举的 ...

  2. P3768 简单的数学题(莫比乌斯反演)

    [题目链接] https://www.luogu.org/problemnew/show/P3768 [题目描述] 求 \(\sum_{i=1}^{n}\sum_{j=1}^{n}i* j* gcd( ...

  3. P1110 [ZJOI2007]报表统计 (multiset)

    [题目链接] https://www.luogu.org/problemnew/show/P1110 有以下三种操作: INSERT i k:在原数列的第i个元素后面添加一个新元素k:如果原数列的第i ...

  4. SQL Server中,varchar和nvarchar如何选择

    正常情况下,我们使用varchar也可以存储中文字符,但是如果遇到操作系统是英文操作系统并且对中文字体的支持不全面时, 在SQL Server存储中文字符为varchar就会出现乱码(显示为??). ...

  5. P5022 旅行 (NOIP2018)

    传送门 先考虑是一颗树的情况 求最小的 dfs 序 显然按儿子编号从小到大dfs 如果有多一条边怎么办 显然会有一条边不用走 直接枚举删那条边然后每次都暴力 dfs 复杂度 $O(n^2)$ 注意每个 ...

  6. Java使用Array类创建多维数组

    1.创建一维数组 import java.lang.reflect.Array; public class ArrayTest { public static void main(String[] a ...

  7. 微信小程序多图上传/朋友圈传图效果【附完整源码】

    效果图 部分源代码 js文件: var uploadPicture = require('../Frameworks/common.js') //获取应用实例 const app = getApp() ...

  8. windows查看网络常用cmd命令

    一.ping 主要是测试本机TCP/IP协议配置正确性与当前网络现状.  ping命令的基本使用格式是: ping IP地址/主机名/域名 [-t] [-a] [-n count] [-l size] ...

  9. scanf()函数的注意事项

    /* 2 time:2018年5月23日18:57:52 3 author:Howie Tang 4 title:scanf()函数的总结 5 */ #include <stdio.h> ...

  10. PlayMaker Play Sound 和 Audio Play

    这两个 Action 都可以播放声音 *Play Sound:只要把声音拖进去就可以: *Audio Play:要求游戏对象要有Audio Source组件.