📜  pythons os 模块选择随机文件 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:38.694000             🧑  作者: Mango

代码示例1
import os
import random
import dircache

dir = 'some/directory'
filename = random.choice(dircache.listdir(dir))
path = os.path.join(dir, filename)