我需要按日期对列表列表进行排序:
mylist=['ML-M01 Qual Report 07/31/13', 'ML36220010 Complete Qual Testing 07/24/13', 'ML36220045 Final FRB 07/13/13', 'ML9822D2600 Brief to PM 08/5/13']
从这个网站,我得到了这个代码:
sorted(mylist, key=lambda x: datetime.datetime.strptime(x[2], '%m/%d/%y'))
但是,我收到此错误消息:
sorted(mylist,key=lambda x: datetime.datetime.strptime(x[2], '%m/%d/%y'))
Traceback (most recent call last):
File "<pyshell#25>", line 1, in <module>
sorted(mylist,key=lambda x: datetime.datetime.strptime(x[2], '%m/%d/%y'))
File "<pyshell#25>", line 1, in <lambda>
sorted(mylist,key=lambda x: datetime.datetime.strptime(x[2], '%m/%d/%y'))
File "C:\Python25\Lib\_strptime.py", line 330, in strptime
(data_string, format))
ValueError: time data did not match format: data=- fmt=%m/%d/%y
需要帮助 - 需要按 3d 元素对列表进行排序 - 最旧到最新