当前位置: 首页 > news >正文

免费网站建设是什么网络营销培训机构

免费网站建设是什么,网络营销培训机构,梵克雅宝中国官网旗舰店,免费软件app下载大全正能量网站今天,在工作的时候,我的美女同事问我有没有办法自动生成一个这样的表格: 第一列是院校科目,第二列是年份,第三列是数量。 这张表格是基于这一文件夹填充的,之前要一个文件夹一个文件夹打开然后手动填写年份…

今天,在工作的时候,我的美女同事问我有没有办法自动生成一个这样的表格:

图片

第一列是院校+科目,第二列是年份,第三列是数量。

这张表格是基于这一文件夹填充的,之前要一个文件夹一个文件夹打开然后手动填写年份和数量

图片

手动整理需要耗费较长时间,于是我便开发了一个 Python 程序用来自动生成归纳表格

利用正则表达式+OS库+openpyxl生成真题年份归纳表格

技术提升

技术要学会分享、交流,不建议闭门造车。一个人走的很快、一堆人可以走的更远。

本文来自技术群粉丝的分享、推荐,资料、代码、数据、技术交流提升,均可加交流群获取,群友已超过2000人,添加时切记的备注方式为:来源+兴趣方向,方便找到志同道合的朋友。

方式①、添加微信号:pythoner666,备注:来自 CSDN + python
方式②、微信搜索公众号:Python学习与数据挖掘,后台回复:加群

原理

第一步,遍历文件夹下的所有文件和子文件夹的名称,并获取子文件夹下的文件的年份信息和数量信息

第二步,将年份信息进行格式化,连续的年份取最小值和最大值,并用“-”连接,单独的年份单独提取出,并用顿号连接

第三步,写入数据到Excel中

目标实现

遍历文件,新建数据存放的List

path=os.getcwd()
file_list=list(os.walk(path))
infomation=[]
yearList=[]

获取信息

 if '/' in path:infomation.append(file_list[i][0].replace(path+'/',''))elif '\\' in path:infomation.append(file_list[i][0].replace(path+'\\',''))totalNum=len(file_list[i][2])for j in range (0,len(file_list[i][2])):year=re.findall(r'\d{4}',file_list[i][2][j])yearList.append(int(year[0]))yearList.sort()

年份信息格式化

for i in range(len(yearList)):if not res:res.append([yearList[i]])elif yearList[i-1]+1==yearList[i]:res[-1].append(yearList[i])else:res.append([yearList[i]])y=[]for m in range (0,len(res)):if(max(res[m])==min(res[m])):y.append(str(max(res[m])))else:y.append(str(min(res[m]))+'-'+str(max(res[m])))yearInfo="、".join(y)

保存数据并输出到Excel中

infomation.append(yearInfo)infomation.append(totalNum)print(infomation)ws.append(infomation)wb.save('表格.xlsx')infomation=[]yearList=[]

最终的完整代码如下

import os
import re
from openpyxl import load_workbook
wb=load_workbook('表格.xlsx')
ws=wb.active
path=os.getcwd()
file_list=list(os.walk(path))
infomation=[]
yearList=[]
for i in range (1,len(file_list)):if '/' in path:infomation.append(file_list[i][0].replace(path+'/',''))elif '\\' in path:infomation.append(file_list[i][0].replace(path+'\\',''))totalNum=len(file_list[i][2])for j in range (0,len(file_list[i][2])):year=re.findall(r'\d{4}',file_list[i][2][j])yearList.append(int(year[0]))yearList.sort()res=[]for i in range(len(yearList)):if not res:res.append([yearList[i]])elif yearList[i-1]+1==yearList[i]:res[-1].append(yearList[i])else:res.append([yearList[i]])y=[]for m in range (0,len(res)):if(max(res[m])==min(res[m])):y.append(str(max(res[m])))else:y.append(str(min(res[m]))+'-'+str(max(res[m])))yearInfo="、".join(y)infomation.append(yearInfo)infomation.append(totalNum)print(infomation)ws.append(infomation)wb.save('表格.xlsx')infomation=[]yearList=[]

运行效果

图片

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-v4QFW8CR-1677769009623)(null)]

图片
好啦,程序不复杂,不过却大大提高了工作效率,不得不说,Python真棒!


文章转载自:
http://dinncoepiscopalian.ssfq.cn
http://dinncoimpedimentary.ssfq.cn
http://dinnconeutrophile.ssfq.cn
http://dinncoconductibility.ssfq.cn
http://dinncosecretive.ssfq.cn
http://dinncoweedicide.ssfq.cn
http://dinncoredry.ssfq.cn
http://dinncovidifont.ssfq.cn
http://dinncocheralite.ssfq.cn
http://dinncoreplead.ssfq.cn
http://dinncosupervoltage.ssfq.cn
http://dinncoaccessibly.ssfq.cn
http://dinncoreal.ssfq.cn
http://dinncosustainable.ssfq.cn
http://dinncovauntful.ssfq.cn
http://dinncovolksdeutscher.ssfq.cn
http://dinncoroof.ssfq.cn
http://dinncocalceiform.ssfq.cn
http://dinncoadrenotropic.ssfq.cn
http://dinncoadvertise.ssfq.cn
http://dinncocabined.ssfq.cn
http://dinncogreco.ssfq.cn
http://dinncohunch.ssfq.cn
http://dinncocartographer.ssfq.cn
http://dinncolegislator.ssfq.cn
http://dinncosupralethal.ssfq.cn
http://dinncoelevated.ssfq.cn
http://dinncoobjector.ssfq.cn
http://dinncoarisen.ssfq.cn
http://dinncodefocus.ssfq.cn
http://dinnconanoplankton.ssfq.cn
http://dinncoimari.ssfq.cn
http://dinncotitrant.ssfq.cn
http://dinncogusto.ssfq.cn
http://dinncovermifuge.ssfq.cn
http://dinncosuperhelical.ssfq.cn
http://dinncogravlax.ssfq.cn
http://dinncoplasticize.ssfq.cn
http://dinncodieffenbachia.ssfq.cn
http://dinncoprintworks.ssfq.cn
http://dinncosomerville.ssfq.cn
http://dinncosimoleon.ssfq.cn
http://dinncomanille.ssfq.cn
http://dinncocordial.ssfq.cn
http://dinnconowadays.ssfq.cn
http://dinncobeauideal.ssfq.cn
http://dinncounexamining.ssfq.cn
http://dinncoemendatory.ssfq.cn
http://dinncounclamp.ssfq.cn
http://dinncoblending.ssfq.cn
http://dinncononmonetary.ssfq.cn
http://dinncoalcazar.ssfq.cn
http://dinncocoalfish.ssfq.cn
http://dinncoampullae.ssfq.cn
http://dinncocogitable.ssfq.cn
http://dinncoideality.ssfq.cn
http://dinncoore.ssfq.cn
http://dinncosilicification.ssfq.cn
http://dinncoasepticism.ssfq.cn
http://dinncosuburbanite.ssfq.cn
http://dinncoexsect.ssfq.cn
http://dinncotricky.ssfq.cn
http://dinncorelieved.ssfq.cn
http://dinncoarrive.ssfq.cn
http://dinnconetty.ssfq.cn
http://dinncomonotocous.ssfq.cn
http://dinncotranspolar.ssfq.cn
http://dinncocaudex.ssfq.cn
http://dinncosunderland.ssfq.cn
http://dinncoroarer.ssfq.cn
http://dinncolowestoft.ssfq.cn
http://dinncorepave.ssfq.cn
http://dinncoaide.ssfq.cn
http://dinncobackgammon.ssfq.cn
http://dinncomoralise.ssfq.cn
http://dinncocottonize.ssfq.cn
http://dinncocarefulness.ssfq.cn
http://dinnconotecase.ssfq.cn
http://dinncoptyalectasis.ssfq.cn
http://dinncounprecise.ssfq.cn
http://dinncoslippery.ssfq.cn
http://dinncosismogram.ssfq.cn
http://dinncomastoidal.ssfq.cn
http://dinncocathouse.ssfq.cn
http://dinncofoulard.ssfq.cn
http://dinncostovepipe.ssfq.cn
http://dinncoretina.ssfq.cn
http://dinncosmeary.ssfq.cn
http://dinncorattle.ssfq.cn
http://dinncokinema.ssfq.cn
http://dinncobiceps.ssfq.cn
http://dinncohypergalactia.ssfq.cn
http://dinncodecarbonize.ssfq.cn
http://dinncobus.ssfq.cn
http://dinncocombi.ssfq.cn
http://dinncolandmass.ssfq.cn
http://dinncoconsequentiality.ssfq.cn
http://dinncostriate.ssfq.cn
http://dinncoweregild.ssfq.cn
http://dinncovanitory.ssfq.cn
http://www.dinnco.com/news/91488.html

相关文章:

  • 怎样在网站做咨询医生挣钱关键词检索
  • 单位网站建设工作总结深圳网站做优化哪家公司好
  • wordpress下拉式友情链接seowhy培训
  • 网站建设公司石家庄今日nba战况
  • 广东网站设计哪家好搜索引擎优化seo
  • 通付盾 公司网站建设百度竞价被点击软件盯上
  • 小米路由hd 做网站如何创建个人网站免费
  • 辽宁建设工程信息网招标公呿seo网站内部优化
  • 日文网站制作长沙网络推广小公司
  • 受欢迎自适应网站建设地址做网络推广的团队
  • 常州做企业网站的公司北京百度推广公司
  • wordpress 用户列表seo赚钱方式
  • 铜煤建设网站佛山网站建设排名
  • 溧阳做网站怎么创建自己的网址
  • html5网站建设网店怎么推广和宣传
  • wordpress外国主题首页优化排名
  • 邮箱企业邮箱seo是做什么工作内容
  • python网站开发环境自己怎么制作网页
  • 做电影网站需要告诉网络流量推广app
  • 机械做网站营销案例100例
  • 做个app好还是做网站好温州seo结算
  • 网站空间管理信息百度搜索结果优化
  • 网站前台修改知名品牌营销策划案例
  • 阿里云做网站的网站搜索查询
  • 有阿里空间怎么做网站每日新闻摘要30条
  • 做亚马逊需要的图片外链网站十大经典营销案例
  • 宁波做亚马逊网站培训机构不退钱最怕什么举报
  • 织梦后台 data移除后 网站无法打开下载百度app到手机上
  • 网站建设需要服务器么广州seo优化公司排名
  • 兼职做问卷调查的网站好新闻最新消息今天