首先导入time,和datetime包
import datetime
import time
if __name__ == '__main__':
dt=sys.argv[1]
myday = datetime.datetime( int(dt[0:4]),int(dt[5:7]),int(dt[8:10]) ) + datetime.timedelta(days=-1)
dt = myday.strftime('%Y-%m-%d')
timestamp = int(time.mktime(time.strptime(dt, "%Y-%m-%d")))
print dt
datetime.timedelta()
now_time = datetime.datetime.now()
yes_time = now_time + datetime.timedelta(days=-2)
# yes_time_nyr = last_time.strftime('%Y%m%d')
print now_time
print yes_time
print yes_time.strftime('%Y-%m-%d')
2015-03-31
2015-04-01 10:46:28.099195
2015-03-30 10:46:28.099195
2015-03-30