![b348c3bed9e2c33853a4f414cdddceb1.png](https://img-blog.csdnimg.cn/img_convert/b348c3bed9e2c33853a4f414cdddceb1.png)
前言:
在财务数据处理和分析中,时间数据尤为重要,Python 程序能用很多方式处理日期和时间。较常用的是 time 和 datetime 模块,可以用于格式化日期和进行时间计算。
Python中时间的几种表现形式:
- time模块:时间戳,时间元组,时间字符串
- datetime模块:datetime数据类型
time模块
01 引入模块
import time
02 时间戳
时间戳是以秒为单位的浮点小数。每个时间戳都以自从1970年1月1日午夜(历元)经过了多长时间来表示。时间戳单位最适于做日期运算。
time.time() # 返回当前时区的时间戳
#输出结果->1582187550.7324438
03 时间元组
时间元祖(struct_time元组)包含9个整型内容: