Python:从给定日期开始和结束一周的数据
day = "13/Oct/2013" print("Parsing :",day) day, mon, yr= day.split("/") sday = yr+" "+day+" "+mon myday = time.strptime(sday, '%Y %d %b') Sstart = yr+" "+time.strftime("%U",myday )+" 0" Send = yr+" "+time.strftime("%U",myday )+" 6" startweek = time.strptime(Sstart, '%Y %U %w') endweek = time.strptime(Send, '%Y %U %w') print("Start of week:",time.strftime("%a, %d %b %Y",startweek)) …