linuxchao

记录一下这个方法,感觉很有用!>.<

 1 import os
 2 def find_newest_file(path_file):
 3     lists = os.listdir(path_file)
 4     lists.sort(key=lambda fn: os.path.getmtime(path_file +\'\\\'+fn))
 5     print(lists)
 6     file_newest = os.path.join(path_file,lists[-1])
 7     return file_newest
 8 if __name__ ==\'__main__\':
 9     file_newest = find_newest_file(r\'D:\pythoncode\login_test\report\')
10     print(file_newest)

分类:

技术点:

相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-05
  • 2022-01-07
相关资源
相似解决方案