没有合适的资源?快使用搜索试试~ 我知道了~
前言 由于在公司接触大量的关于公民隐私的数据,所以才有了这个代码,菜鸟程序员,所以代码方面不是写的很漂亮。这篇代码是为了扫描出所有含有身份证号的excel,并移动到相应的文件夹内,创建日志、解压压缩包等,逻辑很简单,具体的可以看代码,都有注释。后面print()比较多,是因为最后我是把这篇代码用pyinstaller打包成exe程序,给其他同事使用。桌面窗口程序自己不是很熟练,所以没加。 当然根据这个代码,也可以写出像电脑管家杀毒那样,扫描所有文件,挑出你所需要的文件。 代码 # coding=utf-8 import os import re import sys import xlrd i
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/14858148/bg1.jpg)
python扫描文件代码扫描文件代码
前言前言
由于在公司接触大量的关于公民隐私的数据,所以才有了这个代码,菜鸟程序员,所以代码方面不是写的很漂亮。这篇代码是
为了扫描出所有含有身份证号的excel,并移动到相应的文件夹内,创建日志、解压压缩包等,逻辑很简单,具体的可以看代
码,都有注释。后面print()比较多,是因为最后我是把这篇代码用pyinstaller打包成exe程序,给其他同事使用。桌面窗口
程序自己不是很熟练,所以没加。
当然根据这个代码,也可以写出像电脑管家杀毒那样,扫描所有文件,挑出你所需要的文件。
代码代码
# coding=utf-8
import os
import re
import sys
import xlrd
import time
import shutil
import zipfile
import datetime
from unrar import rarfile
class Logger(object):
"""
重写log日志类方法
"""
def __init__(self, fileN="Default.log"):
self.terminal = sys.stdout
self.log = open(fileN, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
pass
def traversal_zip(root_path):
"""
扫描出所有的压缩文件,并输出路径
:param root_path:
:return:
"""
list_rar = [] list_zip = [] list_7z = [] list_files = os.walk(root_path)
for dirpath, dirnames, filename in list_files:
for file in filename:
path_file = os.path.join(dirpath, file)
if re.search("\.7z$", path_file):
list_7z.append([dirpath, path_file])
elif re.search("\.zip$", path_file):
list_zip.append([dirpath, path_file])
elif re.search("\.rar$", path_file):
list_rar.append([dirpath, path_file])
else:
pass
return list_zip, list_rar, list_7z
def traversal_xlsx(root_path):
"""
扫描主目录下,所有的excel文件,并输出路径
:param root_path:
:return:
"""
list_path_file = [] list_path = [] list_files = os.walk(root_path)
for dirpath, dirnames, filename in list_files:
for file in filename:
path_file = os.path.join(dirpath, file)
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38683488
- 粉丝: 4
- 资源: 957
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 网络爬虫软件研究与开发pdf
- Java项目-基于SSM+JSP的母婴用品网站的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- 基于微信小程序的购物商城app设计带Java后端+源代码+文档说明+数据库.zip
- 基于51单片机外设应用设计.DSN后缀PROTEUS仿真仿真源文件及C语言实例源码例程合集(300个).zip
- “Bunnies and Badgers”兔子和獾和是一个基于pygame库开发的射击游戏
- 华为打印机,华为打印机资料
- Java项目-基于SSM+JSP的医院门诊挂号系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- mac os button功能demo
- 如何在Ubuntu上安装软件?
- 华为HCIA-WLAN 3.0 课程视频(20 熟悉命令行.mp4)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)