1 Star 0 Fork 2

w4sevens / python-word-process

forked from ypftest / python-word-process 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
python-docx-remove-temp.py 713 Bytes
一键复制 编辑 原始数据 按行查看 历史
杨鹏飞 提交于 2020-08-21 17:41 . 分步处理更新
"""
删除临时文件
"""
import os
# 读取文件夹下的特定前缀的文件名列表
def file_name(file_dir, file_prefix):
file_list = []
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[0].startswith(file_prefix):
file_list.append(os.path.join(root, file))
return file_list
def main():
file_list = file_name("D:\\文件处理\\2020.8.12-350篇足球", "~$")
print(len(file_list))
for file in file_list:
try:
os.remove(file)
except FileNotFoundError:
print("文件不存在" + file)
print("~$临时文件删除完毕")
if __name__ == '__main__':
main()
Python
1
https://gitee.com/w4dll/python-word-process.git
git@gitee.com:w4dll/python-word-process.git
w4dll
python-word-process
python-word-process
master

搜索帮助