__author__ = "JentZhang"

 import time

 # Timestamp  时间戳
print("Timestamp 时间戳:")
print(time.time())
print("#".center(50,"#")) # Structime 结构化时间
print("Structime 结构化时间:")
print(time.gmtime())
print(time.localtime())
print(time.struct_time)
print("#".center(50,"#")) # 格式化时间为能看得懂的格式
print("格式化时间为能看得懂的格式:")
print(time.strftime("%Y-%m-%d %X", time.localtime()))
print(time.strftime("%Y-%m-%d %X"))
print(time.strftime("%Y-%m-%d %H:%M:%S"))
print("#".center(50,"#")) import datetime # 计算3天前的当前时间
print("计算3天前的当前时间:")
time_str = (datetime.datetime.now() + datetime.timedelta(-3))
print(type(time_str))
print(time_str.strftime("%Y-%m-%d %H:%M:%S"))
# print(datetime.date)

python3中time模块与datetime模块的简单用法的更多相关文章

  1. python中time模块和datetime模块

    time模块和datetime模块 时间分为三种模式(time 模块) 时间戳   (time.time()) 格式化字符串 (time.strftime(%Y-%m-%d %H:%M:%S %p)) ...

  2. Time模块和datetime模块

    Time模块和datetime模块 一. 调用 import time       #调用time模块 二.使用方法 1.time.time 拿到时间戳.以Linux诞生年份1970年开始计算到程序执 ...

  3. Python之路(第十六篇)xml模块、datetime模块

    一.xml模块 xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但json使用起来更简单, xml比较早,早期许多软件都是用xml,至今很多传统公司如金融行业的很多系统的接口还主要 ...

  4. (转)python time模块和datetime模块详解

    python time模块和datetime模块详解 原文:http://www.cnblogs.com/tkqasn/p/6001134.html 一.time模块 time模块中时间表现的格式主要 ...

  5. python time模块 sys模块 collections模块 random模块 os模块 序列化 datetime模块

    一 collections模块 collections模块在内置的数据类型,比如:int.str.list.dict等基础之上额外提供了几种数据类型. 参考博客 http://www.pythoner ...

  6. python3 time模块与datetime模块

    time模块 在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素.由于Python的time模块实现主要调用C库,所以各个平 ...

  7. 详解:Python2中的urllib、urllib2与Python3中的urllib以及第三方模块requests

    在python2中,urllib和urllib2都是接受URL请求的相关模块,但是提供了不同的功能.两个最显著的不同如下: 1.urllib2可以接受一个Request类的实例来设置URL请求的hea ...

  8. python time模块和datetime模块详解

    一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...

  9. python time模块和datetime模块

    一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...

  10. day21 Pythonpython time模块和datetime模块详解

    一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...

随机推荐

  1. [AtCoder3856]Ice Rink Game - 模拟

    Problem Statement An adult game master and N children are playing a game on an ice rink. The game co ...

  2. 弄懂CNN,然后提升准确率4.21-4.27

    英语: 1.每天背单词,75起步.(这周没怎么背,考虑调整了) 2.并背王江涛图画作文一:传统文化(这周没背,但肯定要做) 学校: 0.吴恩达ML 1.毕设一:可视化,肺癌基因突变,深度学习(那么作图 ...

  3. nginx + springboot 配置

    1.spring boot 访问地址http://localhost:13000/test/hello 2.配置nginx.conf文件 upstream my_ngix { server local ...

  4. 神经网络_线性神经网络 1 (Nerual Network_Linear Nerual Network 1)

    2019-04-08 16:59:23 1 学习规则(Learning Rule) 1.1 赫布学习规则(Hebb Learning Rule) 1949年,Hebb提出了关于神经网络学习机理的“突触 ...

  5. Paper Reading——LEMNA:Explaining Deep Learning based Security Applications

    Motivation: The lack of transparency of the deep  learning models creates key barriers to establishi ...

  6. Mesos源码分析(9): Test Framework的启动

    我们以Test Framework为例子解释Framework的启动方式. Test Framework的代码在src/examples/test_framework.cpp中的main函数 首先要指 ...

  7. 【RL-TCPnet网络教程】第3章 初学RL-TCPnet的准备工作及其快速上手

    第3章       初学RL-TCPnet的准备工作及其快速上手 俗话说万事开头难,学习一门新的知识,难的往往不是知识本身,而是如何快速上手,需要什么资料和开发环境.一旦上手后,深入的学习就相对容易些 ...

  8. 全面盘点当前Android后台保活方案的真实运行效果(截止2019年前)

    本文原作者“minminaya”,作者网站:minminaya.cn,为了提升文章品质,即时通讯网对内容作了幅修订和改动,感谢原作者. 1.引言 对于IM应用和消息推送服务的开发者来说,在Androi ...

  9. [Swift]LeetCode21. 合并两个有序链表 | Merge Two Sorted Lists

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  10. [Swift]LeetCode523. 连续的子数组和 | Continuous Subarray Sum

    Given a list of non-negative numbers and a target integer k, write a function to check if the array ...