python中常用的便捷巧妙的方法

1.获取某个目录下面所有匹配的文件list

from glob import glob
files = glob("../checkpoints_path/*.json")
files

out:

['../checkpoints_path\\copy-task-1-batch-1000.json',
 '../checkpoints_path\\copy-task-1-batch-1500.json',
 '../checkpoints_path\\copy-task-1-batch-2000.json',
 '../checkpoints_path\\copy-task-1-batch-2500.json',
 '../checkpoints_path\\copy-task-1-batch-3000.json',
 '../checkpoints_path\\copy-task-1-batch-500.json']

 

posted @ 2022-05-19 19:58  光彩照人  阅读(36)  评论(0)    收藏  举报