Home  >  Article  >  Backend Development  >  python计算N天之后日期的方法

python计算N天之后日期的方法

WBOY
WBOYOriginal
2016-06-10 15:16:381831browse

本文实例讲述了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程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn