标签:获取 几分钟 strftime number shell form 结构 http inf
import time
print(time.time()) # 1585530575.6760194
print(time.time() + 86400*3)
import time print(time.strftime(‘%Y-%m-%d %X‘)) # 2020-03-30 09:09:35 print(time.strftime(‘%Y-%m-%d %H:%M:%S‘)) # 2020-03-30 09:09:35 print(time.strftime(‘%Y-%m-%d %H:%M:%S %p‘)) # 2020-03-30 09:09:35 AM
import time
res = time.localtime()
print(res) # time.struct_time(tm_year=2020, tm_mon=3, tm_mday=30, tm_hour=9, tm_min=11, tm_sec=14, tm_wday=0, tm_yday=90, tm_isdst=0)
print(res.tm_year) # 当前的年:2020
print(res.tm_yday) # 当年的第几天:90
print(res.tm_hour) # 当天的第几个小时:9
print(res.tm_min) # 当天小时的第几分钟:20
print(res.tm_sec) # 当天小时的第几秒钟:27
print(res.tm_mday) # 当月的第几天:30
print(res.tm_mon) # 当年的第几个月:3
print(res.tm_wday) # 当周的第几天-1:0
print(res.tm_zone) # 当前的时间区域
import datetime print(datetime.datetime.now()) # 显示当前时间:2020-03-30 09:25:13.923937 print(datetime.datetime.now() + datetime.timedelta(days=3)) # 计算3天后的时间:2020-04-02 09:25:13.923937 print(datetime.datetime.now() + datetime.timedelta(weeks=1)) # 计算1周后的时间:2020-04-06 09:26:35.199914
import time
s_time = time.localtime()
print(time.mktime(s_time)) # 1585532088.0
import time import datetime tp_time = time.time() print(time.localtime(tp_time)) # time.struct_time(tm_year=2020, tm_mon=3, tm_mday=30, tm_hour=9, tm_min=34, tm_sec=48, tm_wday=0, tm_yday=90, tm_isdst=0) import time import datetime print(time.localtime()) # 上海时区(东八区) print(time.gmtime()) # 世界标准时间 print(time.localtime(333333)) # 时间戳,输入几秒,北京时间 print(time.gmtime(333333)) # 时间戳,输入几秒,世界标准时间
import time
import datetime
s_time = time.localtime()
print(time.strftime(‘%Y-%m-%d %H:%M:%S‘, s_time))
import time
import datetime
print(time.strptime(‘1988-03-03 11:11:11‘, ‘%Y-%m-%d %H:%M:%S‘))
# ‘1998-09-30 11:11:11‘ + 7
import time
import datetime
struct_time = time.strftime(‘1998-03-03 11:11:11‘, ‘%Y-%m-%d %H:%M:%S‘)
timestamp = time.mktime(struct_time) + 7*86400
print(timestamp)
import time
import datetime
res = time.strftime(‘%Y-%m-%d %X‘,time.localtime(timestamp))
print(res)
import time
print(time.asctime()) # Mon Mar 30 09:52:17 2020 常用于Linux操作系统
import datetime
print(datetime.datetime.now()) # 北京时间
print(datetime.datetime.utcnow()) # 世界标准时间
print(datetime.datetime.fromtimestamp(33333)) # 直接把时间戳转换成标准时间
标签:获取 几分钟 strftime number shell form 结构 http inf
原文地址:https://www.cnblogs.com/zhww/p/12983995.html