解析各种文本的年月日
def str2date(str_date):str_date=str_date.strip()if(len(str_date)>11):str_date=str_date[:11]if(str_date.find('-')>0):year=str_date[:4]if(year.isdigit()):year=int(year)else:year=0month=str_date[5:str_date.rfind('-')]if(month.isdigit()):month=int(month)else:month=0if(str_date.find(' ')==-1):day=str_date[str_date.rfind('-')+1:]else:day=str_date[str_date.rfind('-')+1:str_date.find(' ')]if(day.isdigit()):day=int(day)else:day=0elif(str_date.find('年')>0):year=str_date[:4]if(year.isdigit()):year=int(year)else:year=0month=str_date[5:str_date.rfind('月')]if(month.isdigit()):month=int(month)else:month=0day=str_date[str_date.rfind('月')+1:str_date.rfind('日')]if(day.isdigit()):day=int(day)else:day=0elif(str_date.find('/')>0):year=str_date[:4]if(year.isdigit()):year=int(year)else:year=0month=str_date[5:str_date.rfind('/')]if(month.isdigit()):month=int(month)else:month=0if(str_date.find(' ')==-1):day=str_date[str_date.rfind('/')+1:]else:day=str_date[str_date.rfind('/')+1:str_date.find(' ')]if(day.isdigit()):day=int(day)else:day=0if month<10:month='0'+str(month)if day<10:day='0'+str(day)return '%s-%s-%s' % (year,month,day)