惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
云风的 BLOG
云风的 BLOG
IT之家
IT之家
The Register - Security
The Register - Security
博客园_首页
博客园 - 聂微东
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
腾讯CDC
F
Full Disclosure
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
MyScale Blog
MyScale Blog
T
Tailwind CSS Blog
Jina AI
Jina AI
月光博客
月光博客
A
About on SuperTechFans
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Help Net Security
博客园 - Franky
Vercel News
Vercel News
美团技术团队
C
CERT Recently Published Vulnerability Notes
Security Latest
Security Latest
Scott Helme
Scott Helme
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
www.infosecurity-magazine.com
www.infosecurity-magazine.com
SecWiki News
SecWiki News
The Last Watchdog
The Last Watchdog
U
Unit 42
The Cloudflare Blog
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
T
Tenable Blog
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
B
Blog
Webroot Blog
Webroot Blog
A
Arctic Wolf
S
SegmentFault 最新的问题
aimingoo的专栏
aimingoo的专栏
AWS News Blog
AWS News Blog
I
Intezer
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

博客园 - zzuCharles

Qwen-Max 8G 内存本地部署方案(轻量化可用版) MFC中使用多线程 高性能 Flink SQL 优化 Flink 时间概念 EventTime 和 Watermark SQL 优化(来源平时总结及网络分享) hadoop 查询优化 python 读取csv多编码兼容读取 文件拆分-python Mysql 调优笔记 Python 输出菱形 Python 猜数小程序(练习) Mysql 字符串日期互转 MaxCompute 语句笔记 数据仓库架构 Python 比较两个字符串的相似度 Python print Python简单计算器 用户价值模型 CITE :https://www.jianshu.com/p/34199b13ffbc 用户生命周期模型
Python 读取目录,office文件分类
zzuCharles · 2020-05-21 · via 博客园 - zzuCharles
import os
dict_suffix   ={'doc':[],'docx':[],
          'xls':[],'xlsx':[],
          'ppt':[],'pptx':[]}

def lsdir(path):
    for dirpath,dirnames,filenames in os.walk(path):
        for filename in filenames:  
            suffix=filename[filename.rfind(r'.')+1:len(filename)].lower() 
            if suffix in dict_suffix:
                dict_suffix[suffix].append(os.path.join(dirpath,filename))
    return  dict_suffix
      
  
        

if __name__ == '__main__': 
   # pl = r'D:\workspace\数据字典'
    old_pl=input('请输入路径:')
    if old_pl[-1] =='\/':
        old_pl=old_pl[0:len(old_pl)-1]
    pl=old_pl.replace('\/', '\/\/')
    dic=lsdir(pl)
    for i in dic:
        if len(dic[i])>0 :
            print('文件类型:',i)
            [print(s) for s in dic[i]]