Python 3.6.4

import time, calendar, datetime

print("距离1970年的秒数为:", time.time())
print("本地时间为:", time.localtime())
print("格式化:", time.asctime(time.localtime(time.time())))
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) # 输出
# 距离1970年的秒数为: 1518107142.14775

 # 本地时间为: time.struct_time(tm_year=2018, tm_mon=2, tm_mday=9, tm_hour=0, tm_min=25, tm_sec=42, tm_wday=4, tm_yday=40, tm_isdst=0)
  #格式化: Fri Feb 9 00:25:42 2018
  # 2018-02-09 00:25:42

# 打印日历
print(calendar.month(, ))
# 下面是利用datetime输出时间,个人觉得比上面那种方法简单好用
i = datetime.datetime.now();
print(i)
print("格式化(年/月/日 时:分:秒):%s/%s/%s %s:%s:%s"
% (i.year, i.month, i.day, i.hour, i.minute, i.second)
)
# 以下为输出结果

March 2018
Mo Tu We Th Fr Sa Su
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 31


2018-02-09 00:25:42.179003
格式化(年/月/日 时:分:秒):2018/2/9 0:25:42


参考:http://www.runoob.com/python/python-date-time.html

最新文章

  1. ajax
  2. 了解HTML表单之13个表单控件
  3. QTableWidget控件总结<一>
  4. 【译】java.lang.ThreadLocal
  5. 检测当前运行环境——移动端与PC端。
  6. Codeforces Round #216 (Div. 2)解题报告
  7. javascript类,对象,实例
  8. Shell: extract more from listener.log(分析监听日志)
  9. oracle ed命令
  10. iOS_20_微博的骨架结构
  11. 为什么说Neutron不是SDN?
  12. 自己封装的一个js方法用于获取显示的星期和日期时间
  13. [Python Study Notes]计算cpu使用率v0.1
  14. 关于在spring boot里使用Thymeleaf模板的application.properties配置
  15. 2017-12-14python全栈9期第一天第二节之初始计算机系统
  16. Vue(六)过滤器
  17. 使用 Nuget安装DLL
  18. In-App Purchase iap 内付费 二次验证代码 (java 服务器端)
  19. FCC JS基础算法题(6):Truncate a string(截断字符串)
  20. MacOS 如何剪切文件

热门文章

  1. mybatis内置二级缓存。
  2. 关于nodejs模块安装后找不到包解决办法
  3. Dll加载总是出问题,显示无法加载
  4. android 常用第三方github工程
  5. Ubuntu16.04下使用sublime text3搭建Python IDE
  6. C++通讯录
  7. URAL 1776 Anniversary Firework (概率,区间DP)
  8. Ace 在Vue中使用方法
  9. selenium+chrome浏览器驱动-爬取百度图片
  10. Linux 标准 I/O 库