path = '/www/wwwpython/test/x'
def deleteFile(path, postfix=None):
os.chdir(path)
deleteList = []
for filename in os.listdir(path):
if filename.endswith('.' + postfix):
os.unlink(filename)
deleteList.append(filename)
return '\n'.join(deleteList)
print(deleteFile(path, 'py'))
python 删除指定目录下 某个格式的文件
最新推荐文章于 2024-04-22 11:13:10 发布