【发布时间】:2021-04-18 17:03:18
【问题描述】:
我再次需要你的帮助,我不知道该怎么做
我有一个文件,它看起来像这样:
file.txt:
005-test1
039-test1
008-test1
009-ttest1
003-test1 97F199F
015-test1 C7264DF9
007-test1 5AD753A0
059-test1 CF4BFD2F
我想让文件按数字升序排序,这样在这里看起来像这样
003-test1 97F199F
005-test1
007-test1 5AD753A0
008-test1
009-ttest1
015-test1 C7264DF9
039-test1
059-test1 CF4BFD2F
不幸的是,我不知道该怎么做
【问题讨论】:
-
问题出在哪里?读取文件?分割线?对行列表进行排序?你甚至不尝试这样做......
-
这能回答你的问题吗? How to sort a text file line-by-line
标签: python-3.x