Python: Sort files by date
Python Basic: Exercise-70 with Solution
Write a Python program to sort files by date.
Sample Solution:-
import globimport os
files = glob.glob("*.txt")
files.sort(key=os.path.getmtime)
print("\n".join(files))
abc1.txt
abc.txt
test.txt
>>>
沒有留言:
張貼留言