网站首页 > 技术文章 正文
# -*- coding: UTF-8 -*-
import time
import datetime
#打印时间戳:1650041030.05
print(time.time())
#格式化字符串时间:Sat Apr 16 00:44:44 2022
print(time.ctime())
#time.struct_time(tm_year=2022, tm_mon=4, tm_mday=16, tm_hour=0, tm_min=46, tm_sec=40, tm_wday=5, tm_yday=106, tm_isdst=0)
print(time.localtime())
#Sat Apr 16 00:46:40 2022
print(time.asctime(time.localtime()))
#元组时间转换为时间戳: 1650041341.0
print(time.mktime(time.localtime()))
#元组时间转换为字符串时间: 16-04
print(time.strftime("%d-%m", time.localtime()))
#年月日:2022/04/16
print(time.strftime("%Y/%m/%d", time.localtime()))
#将时间戳转换为字符串时间: Sat Apr 16 00:55:42 2022
print(time.ctime(time.time()))
#将时间戳转换为时间元组:time.struct_time(tm_year=2022, tm_mon=4, tm_mday=16, tm_hour=0, tm_min=57, tm_sec=22, tm_wday=5, tm_yday=106, tm_isdst=0)
print(time.localtime(time.time()))
#datetime模块
#date对象所能表示的最大、最小日期 9999-12-31
print(datetime.date.max)
#date对象所能表示的最大、最小日期 0001-01-01
print(datetime.date.min)
#返回一个表示当前本地日期的date对象:2022-04-16
print(datetime.date.today())
#将时间戳转换为字符串时间:2022-04-16
print(datetime.date.fromtimestamp(time.time()))
#time模块
序号 | 函数及描述 |
1 | time.altzone |
2 | time.asctime([tupletime]) |
3 | time.clock( ) |
4 | time.ctime([secs]) |
5 | time.gmtime([secs]) |
6 | time.localtime([secs]) |
7 | time.mktime(tupletime) |
8 | time.sleep(secs) |
9 | time.strftime(fmt[,tupletime]) |
10 | time.strptime(str,fmt='%a %b %d %H:%M:%S %Y') |
11 | time.time( ) |
12 | time.tzset() |
猜你喜欢
- 2024-12-12 各种数据文件时间戳服务解决方案
- 2024-12-12 Python中日期、时间处理Arrow类库如何使用
- 2024-12-12 解决AAC音频编码时间戳的计算问题
- 2024-12-12 python 日期、时间处理,各种日期时间格式/字符串?
- 2024-12-12 一个按时间戳排序导致的 Bug
- 2024-12-12 Python的time模块与datetime模块完整使用方法
- 2024-12-12 JAVA常用时间工具类(LocalDateTime)
- 2024-12-12 JS:处理日期时间,实现格式化的方法与简单封装
- 2024-12-12 Python处理日期时间常用的10个操作
- 2024-12-12 WPS JSA日期时间的填 坑已经都给你们填平了 郑广学JSA880
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- oraclesql优化 (66)
- 类的加载机制 (75)
- feignclient (62)
- 一致性hash算法 (71)
- dockfile (66)
- 锁机制 (57)
- javaresponse (60)
- 查看hive版本 (59)
- phpworkerman (57)
- spark算子 (58)
- vue双向绑定的原理 (68)
- springbootget请求 (58)
- docker网络三种模式 (67)
- spring控制反转 (71)
- data:image/jpeg (69)
- base64 (69)
- java分页 (64)
- kibanadocker (60)
- qabstracttablemodel (62)
- java生成pdf文件 (69)
- deletelater (62)
- com.aspose.words (58)
- android.mk (62)
- qopengl (73)
- epoch_millis (61)
本文暂时没有评论,来添加一个吧(●'◡'●)