0
点赞
收藏
分享

微信扫一扫

IDEA 开发工具的常用快捷键

书写经典 2024-11-18 阅读 15

一.创作起源

在我现在的工作中经常要写文件,批量修改文件里面的文件,每次批量打开文件和打印文件,就是很费力,希望python可以帮我解决一下

二.使用注意事项

1.适用wps,不适用office

2.path:文件夹的路径

3.file_extension:文件类型不要加.

4.这段代码采用界面输入路径和文件类型的方式,伙伴们可以直接替换

5.本文运行中主要打开docx文件,其他类型的文件伙伴们可以自行尝试,不断修改,形成自己的

三、批量用wps打开一个文件夹里面的同类文件的代码

import os
import pyautogui as mouse
import time
import re
class runing(object):
    def __init__(self, path, file_extension):
        self.path = path
        self.file_extension = file_extension

    def open_file(self):
        for root, dirs, files in os.walk(self.path, topdown=True):
            for name in files:
                file = os.path.join(root, name)
                if (file.endswith(".%s" % self.file_extension) == True) and ("~$" not in file):
                    print("准备把--%s--打开"
举报

相关推荐

0 条评论