所以我有一个包含一些行的.txt文件。。。
每行的格式如下:x (A-Z) creationDate completionDate Task +project @context
(TODO list project)
所以我想按creationDate(第二种情况下是completionDate)对这些行进行排序,并将它们写入一个.txt文件
示例:
(D) 2018-03-02 2018-04-04 watch the new tomb raider +movie @tombraider
(A) 2017-03-02 2017-03-10 say goodbye to your best friend!! +friendship @meetfriend
x (C) 2016-07-02 2016-08-05 finish gta vice city +gaming @playstation2
排序后:
x (C) 2016-07-02 2016-08-05 finish gta vice city +gaming @playstation2
(A) 2017-03-02 2017-03-10 say goodbye to your best friend!! +friendship @meetfriend
(D) 2018-03-02 2018-04-04 watch the new tomb raider +movie @tombraider
我该怎么做
谢谢你花时间回答
使用
sorted()
和lambda
这假设ever行在位置2处有
creationDate
前缀。然而,正如注释所指出的,是否有些行有x
前缀而有些行没有?如果没有,是否有字符(例如\s
或\t
)相关问题 更多 >
编程相关推荐