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

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

WBOY
Release: 2016-06-10 15:16:38
Original
1872 people have browsed it

本文实例讲述了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()
Copy after login

输出结果如下:

2015-02-18 16:49:28.362000
Fri Feb 18 16:49:28 2015
Copy after login

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template