import datetime,time


#输入时间戳，加减一年，转化成时间戳
def TimestampChange(estiblish_time,num):
    e_time= datetime.datetime.fromtimestamp(estiblish_time) #时间戳转datetime型
    year0 = e_time.year-num#取出相应年份减1
    year1 = e_time.year+num
    month = e_time.month
    day = e_time.day
    hour = e_time.hour
    minute = e_time.minute
    second = e_time.second
    begin_e_time = datetime.datetime(year0,month,day,hour,minute,second)#拼接成上一年的datetime
    end_e_time=datetime.datetime(year1,month,day,hour,minute,second)#拼接成下一年的datetime
    begin_e_time = time.mktime(begin_e_time.timetuple())#转化成时间戳
    end_e_time=time.mktime(end_e_time.timetuple())
    return begin_e_time,end_e_time