---
title: "python 取日期"
author: "jickcai"
date: "2014-01-02T11:11:06Z"
tags: []
categories: ["Web前端"]
slug: "python"
draft: false
lastmod: "2014-01-02T11:11:06Z"
id: 1998229
url: "https://jickcai.iteye.com/blog/1998229"
---

#!/usr/bin/env python

#2天前 

ctime = time.strftime('%Y%m%d',time.localtime(time.time()-2\*24\*60\*60))

print ctime 

 

#1天前 

ctime = time.strftime('%Y%m%d',time.localtime(time.time()-1\*24\*60\*60))

print ctime 

 

#当天 

ctime = time.strftime('%Y%m%d',time.localtime(time.time()))

print ctime