File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ Python技术 公众号文章代码库
1111## 实例代码
1212
1313
14+
15+ [ 美女同事又找我帮忙了,激动!] ( https://github.com/JustDoPython/python-examples/tree/master/fans/filenaming ) :美女同事又找我帮忙了,激动!
16+
1417[ 高效办公,pandas美化表格实例演示] ( https://github.com/JustDoPython/python-examples/tree/master/fans/beautyPandas ) :高效办公,pandas美化表格实例演示
1518
1619[ echarts的可视化] ( https://github.com/JustDoPython/python-examples/tree/master/fans/shift ) :echarts的可视化
Original file line number Diff line number Diff line change 1+ import os
2+ import re
3+ path = os .getcwd ()
4+ fr = open (path + '/gaoxiao-dict.txt' ,'r' ,encoding = 'utf-8' )
5+ dic = {}
6+ keys = []
7+ for line in fr :
8+ v = line .strip ().split (':' )
9+ dic [v [0 ]]= v [1 ]
10+ keys .append (v [0 ])
11+ fr .close ()
12+ #规范命名的函数
13+ def normalReName (name ):
14+ isTikuban = re .findall (r'【题库版】' ,name )
15+ if len (isTikuban )!= 0 :
16+ m = name .replace ('【题库版】' ,'' ).replace ('_' ,'' )
17+ os .rename (name + '.pdf' ,m + '.pdf' )
18+ else :
19+ m = name
20+ s = re .findall (r'.*?大学|.*?学院|.*?(北京)|.*?(华东)|.*?(武汉)' ,m )
21+ university = ''
22+ for i in range (0 ,len (s )):
23+ university += s [i ]
24+ code = re .search ('\d{3}' ,m )
25+ year = re .findall ('\d{4}' ,m )
26+ if '年' in m :
27+ b = m .replace (university + code .group (),'' ).replace (year [0 ]+ '年' ,'' )
28+ else :
29+ b = m .replace (university + code .group (),'' ).replace (year [0 ],'' )
30+ new_name = dic [university ]+ '+' + university + '+' + code .group ()+ b + '+' + year [0 ]+ '年'
31+ os .rename (m + '.pdf' ,new_name + '.pdf' )
32+ file_name_list = os .listdir (path )
33+ for file in file_name_list :
34+ name = file .split ('.' )[0 ]
35+ kuozhan = file .split ('.' )[1 ]
36+ if name != 'watermark' and kuozhan == 'pdf' :
37+ normalReName (name )
You can’t perform that action at this time.
0 commit comments