#!/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. react 的理念

    命名式的编程方式: 命名式的编程方式,我们会有百分之六七十都在进行dom的操作. 1.声名式的开发: react是面向数据开发的,react是根据这个数据自动构建这个网站,可以把数据理解成图纸,rea ...

  2. poj1125传播谣言(弗洛伊德,求最长路)

    Stockbroker Grapevine Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 38541   Accepted: ...

  3. POJ2676 (数独问题 + DLX + 状态优化顺序)

    (1)最简单的最是去暴力DFS搜索答案 , 很容易想到 , 每行每列的方式去搜索 , 不过效率是真的不行;但这个还是给出代码 ,毕竟打了也不容易呀! #include<cstdio> #i ...

  4. day_12 内置函数

      1. 内置函数 1.双下划线方法的使用 1.原来it=lst.__iter__() print(it__next__()) 2.现在it=iter(list) print(next(it)) 2. ...

  5. hdu 6288(二分法加精度处理问题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6288 题意:给出a,b,k,n可满足(n^a)*(⌈log2n⌉)^b<=k ,求最大的n值三个 ...

  6. 2.4 Rust Ownership

    What Is Ownership ownership这个单词有些不好翻译,刚开始就直接叫它“ownership”即可.这里简单说一下,我对它的理解, 从“数据结构与算法”的角度来看,ownershi ...

  7. 在Oracle创建一个自己用的用户及角色

    1.创建一个用户名为LIXIAOLONG,密码为123456的用户. CREATE USER LIXIAOLKONG IDENTIFIED BY 123456; 2.为用户授予连接,资源,管理员角色. ...

  8. 在Mac上安装mysql

    进入这个网站: https://dev.mysql.com/downloads/mysql/ 然后点击安装就行了. 注意在这里启动mysql 然后mac上所有的mysql命令都得用绝对路径才能生效

  9. Android文件/文件夹选择器(支持多选操作),已封装为lib库,直接添加依赖即可。

    话不多少,先上图一览: 接下来我们开始写个app测试: 1.新建Android工程:FileSelectorTest 2.更改MainActivity: 在里面写四个textview模拟button, ...

  10. Linux进程间通信的几种方式

    1.管道及有名管道(pipe & named pipe) pipe 用于亲缘关系的进程间通信,named pipe除了pipe的功能外,还可以进行无亲缘关系进程间的通信. 2.信号(Signa ...