1、把时间类型为"26-JUN-07"的形式转换为"2007-06-26"
def timeconvert(timevalue):
# time="26-JUN-07"
monthname={"JAN":"01","FEB":"02","MAR":"03","APR":"04","MAY":"05","JUN":"06","JUL":"07","AUG":"08","SEP":"09","OCT":"10","NOV":"11","DEC":"12"}
times=timevalue.split('-')
if len(times)!=3:
return "None"
# print times
if len(times[0])==1:
times[0]="0"+times[0]
timenew='20'+times[2]+'-'+monthname[times[1]]+'-'+times[0]
return timenew
参数timevalue为"26-JUN-07"这种形式,结果timenew为"2007-06-26"