#-*- encoding:utf_8 -*-
from docx import Document
from docx.shared import Inches
from log import logger
import os
'''
python docx 批量修改docx文件内容和选择位置添加内容的初步尝试
不喜勿喷♪(^∇^*)
'''
def folder_filelist(pathname):
'''
读取所有文件名,为了实现对文件夹的批处理
'''
filename_list = list()
full_pathname = os.path.abspath(pathname)
if os.path.isfile(full_pathname):
if _is_legal_postfix(full_pathname):
filename_list.append(full_pathname)
else:
raise TypeError('文件 {} 后缀名不合法!仅支持如下文件类型:{}。'.format(pathname, '、'.join(self._handle_postfix)))
elif os.path.isdir(full_pathname):
for relpath, _, files in os.walk(full_pathname):
for name in files:
filename = os.path.join(full_pathname, relpath, name)
if _is_legal_postfix(filename):
filename_list.append(os.path.join(filename))
re
python docx 批量修改docx文件内容和选择位置添加内容
最新推荐文章于 2025-05-20 22:23:34 发布