python计算N天之后日期的方法
作者:songguo 时间:2022-04-20 10:33:51
本文实例讲述了python计算N天之后日期的方法。分享给大家供大家参考。具体如下:
python计算N天之后的日期,可以自己写成一个函数,想得到几天后的日期都行
#! /usr/bin/env python
#coding=utf-8
import time
import datetime
d1 = datetime.datetime.now()
d3 = d1 + datetime.timedelta(days =10)
print str(d3)
print d3.ctime()
输出结果如下:
2015-02-18 16:49:28.362000
Fri Feb 18 16:49:28 2015
希望本文所述对大家的Python程序设计有所帮助。
标签:python,计算,日期
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python函数中return后的语句一定不会执行吗?
2022-03-25 04:06:44
Python对Excel按列值筛选并拆分表格到多个文件的代码
2022-01-18 12:58:46
浅谈python类属性的访问、设置和删除方法
2022-01-12 00:14:48
基于Python编写一个简单的服务注册发现服务器
2022-06-11 20:23:31
![](https://img.aspxhome.com/file/2023/4/65464_0s.png)
Python爬虫模拟登录带验证码网站
2022-02-18 21:33:48
![](https://img.aspxhome.com/file/2023/6/107796_0s.png)
在Python中使用HTML模版的教程
2023-01-17 23:30:38
![](https://img.aspxhome.com/file/2023/1/103111_0s.png)
关于Python-faker的函数效果一览
2023-12-02 21:20:06
浅谈Python几种常见的归一化方法
2021-01-22 16:36:45
![](https://img.aspxhome.com/file/2023/4/66824_0s.gif)
dl.dt.dd.ul.li.ol区别及应用
2008-05-24 09:42:00
![](https://img.aspxhome.com/file/UploadPic/20085/24/200852494731250s.gif)
如何基于python对接钉钉并获取access_token
2023-11-27 04:25:07
Python的Pillow库进行图像文件处理(图文详解)
2023-10-04 04:02:23
![](https://img.aspxhome.com/file/2023/4/62914_0s.png)
python使用for循环和海龟绘图实现漂亮螺旋线
2023-08-01 10:38:57
![](https://img.aspxhome.com/file/2023/5/90425_0s.jpg)
浅谈Python中的bs4基础
2022-11-05 16:57:47
PHP缓存集成库phpFastCache用法
2023-11-14 02:35:19
python操作xml文件示例
2022-06-17 22:38:28
python with提前退出遇到的坑与解决方案
2023-12-24 15:02:35
Python常用时间操作总结【取得当前时间、时间函数、应用等】
2021-01-12 20:32:33
Python with语句和过程抽取思想
2023-08-16 08:08:28
python文件转为exe文件的方法及用法详解
2022-08-18 00:14:17
HTML5硝烟弥漫
2009-07-06 14:44:00