时间和日期
来源:互联网 发布:局部搜索算法历史 编辑:程序博客网 时间:2024/06/05 13:32
获取当前时间戳:
import time
sticks=time.time()
print(sticks)
获取当前时间:
import time
localtime=time.localtime(time.time())
print(localtime)
获取格式化的时间:
用asctime
import time
localtime=time.asctime(time.localtime(time.time()))
格式化日期:
#!/usr/bin/python# -*- coding: UTF-8 -*-import 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"))
以上实例输出结果:
2016-04-07 10:25:09Thu Apr 07 10:25:09 20161459175064.0
获取某月日历:
import calendar
cal=time.month(2017,11)
print(cal)
阅读全文
0 0
- C++日期和时间
- 时间和日期操作
- 时间和日期操作
- 日期和时间模式
- LINUX 时间和日期
- DB2日期和时间
- 操作日期和时间
- 时间和日期格式
- 日期和时间编程
- php 日期和时间
- 日期和时间
- php 日期和时间
- 时间和日期
- LINUX 时间和日期
- Unix时间和日期
- 时间和日期操作
- 时间和日期
- 日期和时间
- spring cloud 前人踩过的坑
- java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \
- 开启Mysql慢查询日志
- 上机练习题——异常处理1
- 函数的重载,
- 时间和日期
- 鼠标右键菜单
- 谈一次java web系统的重构思路
- JAVASE基础之TCP挥手握手
- 影子
- P2P“点融网”凭什么拿得2.07亿美元融资?
- 文章标题
- Windows Networking Troubleshooting.pdf 英文原版 免费下载
- NOIP2017 游记