【2022.06.21】python对日期进行的处理
2022/6/22 1:21:14
本文主要是介绍【2022.06.21】python对日期进行的处理,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
主要是datetime和str之间的互相转化
记录一下
import time import datetime import json # a = datetime.datetime.now() # b = a.strftime("%Y%m%d") # c = a + datetime.timedelta(days=4) # d = c.strftime("%Y%m%d") # e = '2013/10/10' # f = datetime.datetime.strptime(e, '%Y/%m/%d') # print(a) # print(b) # print(c) # print(d) # print(e) # print(f) with open('config.json', 'r', encoding='utf-8') as f: JsonFile = json.load(f) base_url = JsonFile['base_url'] begin_date = JsonFile['begin_date'] begin_date = datetime.datetime.strptime(begin_date, '%Y-%m-%d') date = begin_date now = datetime.datetime.now() while date < now: date = date + datetime.timedelta(days=1) # print(date.strftime("%Y%m%d")) url = base_url + date.strftime("%Y%m%d") + '.dat' print(url)
这篇关于【2022.06.21】python对日期进行的处理的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python