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

企业营销网站有哪些网络营销典型案例

企业营销网站有哪些,网络营销典型案例,音乐中文网站模板下载,做自己的网站给人的启发需求:修改指定目录下所有文件的页眉页脚,或者往里面添加内容。 1. 这里做了word的实现和excel的实现,如下: 需要先安装 pip3 install pywin32,另外页眉页脚格式设置可以参考: word: 浅谈Wor…

需求:修改指定目录下所有文件的页眉页脚,或者往里面添加内容。

1. 这里做了word的实现和excel的实现,如下:

需要先安装 pip3 install pywin32,另外页眉页脚格式设置可以参考:

word:

浅谈Word.Application,关于js操作word文档的使用_new word.application-CSDN博客

excel:

Python操作Excel教程(图文教程,超详细)Python xlwings模块详解,_xlwings教程-CSDN博客

import os
import xlwings as xw
import win32com.client as win32
import pythoncom#将需要替换页眉页脚的文档放到path下
path = r'C:\Users\d\Desktop\pdf改名脚本\22\2022年\test'
#原始页眉页脚内容
old_name = u'999'
#新页眉页脚内容
new_name = u'888'
#替换失败记录日志
err_log = path + u'\\head修改出错列表.txt'
def log(text):with open( err_log,"a+" ) as f:f.write(text)f.write('\n')def change_headerfooter(path):''' 更改文件的页眉页脚 '''pythoncom.CoInitialize()word = win32.Dispatch('Word.Application')#print(dir(word))word.Visible = 0word.DisplayAlerts = 0exapp = xw.App(visible=False, add_book=False)# excel = win32.Dispatch('Excel.Application')# excel.Visible = 0# excel.DisplayAlerts = 0for parent, dirnames, filenames in os.walk(path):for fn in filenames:filedir = os.path.join(parent, fn)#获取需替换目录下的docx结尾的文档名称if fn.endswith('.docx') or fn.endswith('.doc'):print(filedir)try:doc = word.Documents.Open( filedir )a = word.ActiveDocument.Sectionsn = 0for i in range( len(a) ):#获取当前页眉head = word.ActiveDocument.Sections[i].Headers[0]old_head = str(head)#获取当前页脚foot = word.ActiveDocument.Sections[i].Footers[0]old_foot = str(foot)#print( old_head )#if old_name in old_head:if 1:#old_name存在页眉中时,进行进行替换#用于替换页眉#new_head = old_head.replace( old_name, new_name )#用于补充页眉#new_head = old_head + new_name#print( new_head )word.ActiveDocument.Sections[i].Headers[0].Range.Find.ClearFormatting()word.ActiveDocument.Sections[i].Headers[0].Range.Find.Replacement.ClearFormatting()#页眉重置word.ActiveDocument.Sections[i].Headers[0].Range.Delete()#设置字体大小word.ActiveDocument.Sections[i].Headers[0].Range.Font.Size=20#设置对齐方式,0-左;1-中;2-右word.ActiveDocument.Sections[i].Headers[0].Range.ParagraphFormat.Alignment = 0word.ActiveDocument.Sections[i].Headers[0].Range.InsertAfter(new_name)#替换旧页眉#word.ActiveDocument.Sections[i].Headers[0].Range.Find.Execute( old_head, False, False, False, False, False, False, 1, False, new_name, 2 )#if old_name in old_foot:if 1:##old_name存在页脚中时,进行进行替换#new_foot = old_foot.replace( old_name, new_name )#new_foot = old_foot + new_nameword.ActiveDocument.Sections[i].Footers[0].Range.Find.ClearFormatting()word.ActiveDocument.Sections[i].Footers[0].Range.Find.Replacement.ClearFormatting()#页脚重置word.ActiveDocument.Sections[i].Footers[0].Range.Delete()word.ActiveDocument.Sections[i].Footers[0].Range.InsertAfter(new_name)#替换旧页脚#word.ActiveDocument.Sections[i].Footers[0].Range.Find.Execute( old_foot, False, False, False, False, False, False, 1, False, new_name, 2 )n = n+1doc.Close()except Exception as e:print(e)log(str(filedir))if fn.endswith('.xlsx') or fn.endswith('.xls'):print(filedir)try:ex = exapp.books.open(filedir)#print(dir(ex.sheets))sheet = ex.sheetsprint(sheet[0].name)if 'test' == sheet[0].name:print(sheet.name)else:#如果第一个sheet不是test则加一个test的sheetsheet.add('test',before=sheet[0].name)ex.save()ex.close()except Exception as e:log(str(filedir))word.Quit()exapp.quit()change_headerfooter(path)

补充一下:excel没有用pywin32去读写因为莫名其妙就是卡进程,无法对excel读写,可能和缓存的excel有关,如要编辑3.xlsx,则会卡一个~3.xlsx的进程无法结束。就换成了xlwings去读写。


文章转载自:
http://meanwhile.c7493.cn
http://explicans.c7493.cn
http://paramorphism.c7493.cn
http://biro.c7493.cn
http://subprofessional.c7493.cn
http://dashdotted.c7493.cn
http://gypper.c7493.cn
http://cull.c7493.cn
http://osteophyte.c7493.cn
http://familism.c7493.cn
http://maskalonge.c7493.cn
http://unfathered.c7493.cn
http://aspermous.c7493.cn
http://extemporaneous.c7493.cn
http://pannikin.c7493.cn
http://furbearer.c7493.cn
http://sericiculture.c7493.cn
http://eng.c7493.cn
http://jacinth.c7493.cn
http://campshot.c7493.cn
http://diestock.c7493.cn
http://phytotoxin.c7493.cn
http://diamante.c7493.cn
http://pinnigrade.c7493.cn
http://barebacked.c7493.cn
http://salespeople.c7493.cn
http://knocker.c7493.cn
http://dayflower.c7493.cn
http://goffer.c7493.cn
http://reparable.c7493.cn
http://piscator.c7493.cn
http://diffusive.c7493.cn
http://arrivederci.c7493.cn
http://ablative.c7493.cn
http://cobwebbery.c7493.cn
http://whiffet.c7493.cn
http://vertices.c7493.cn
http://zarathustra.c7493.cn
http://triplication.c7493.cn
http://photovaristor.c7493.cn
http://diverting.c7493.cn
http://exochorion.c7493.cn
http://ferromagnetism.c7493.cn
http://kilobit.c7493.cn
http://yank.c7493.cn
http://perishable.c7493.cn
http://montserrat.c7493.cn
http://trapezius.c7493.cn
http://spectator.c7493.cn
http://monosyllable.c7493.cn
http://itacolumite.c7493.cn
http://gearshift.c7493.cn
http://auk.c7493.cn
http://atrip.c7493.cn
http://robotology.c7493.cn
http://arbovirus.c7493.cn
http://reliquary.c7493.cn
http://interseptal.c7493.cn
http://hepatoscopy.c7493.cn
http://impacted.c7493.cn
http://roadeo.c7493.cn
http://condescend.c7493.cn
http://luxuriously.c7493.cn
http://relent.c7493.cn
http://spearfisherman.c7493.cn
http://palaeoethnobotany.c7493.cn
http://reinflation.c7493.cn
http://busier.c7493.cn
http://hybrid.c7493.cn
http://macroeconomic.c7493.cn
http://drawerful.c7493.cn
http://emmet.c7493.cn
http://eater.c7493.cn
http://fetichist.c7493.cn
http://valorous.c7493.cn
http://cantonal.c7493.cn
http://jeans.c7493.cn
http://devout.c7493.cn
http://faciobrachial.c7493.cn
http://glumose.c7493.cn
http://qurush.c7493.cn
http://twimc.c7493.cn
http://bullshot.c7493.cn
http://fiasco.c7493.cn
http://amygdaline.c7493.cn
http://ithun.c7493.cn
http://burton.c7493.cn
http://irishman.c7493.cn
http://plowshoe.c7493.cn
http://motto.c7493.cn
http://negrophilism.c7493.cn
http://neurodepressive.c7493.cn
http://flense.c7493.cn
http://maltase.c7493.cn
http://iconodulic.c7493.cn
http://indisposed.c7493.cn
http://antemarital.c7493.cn
http://centrism.c7493.cn
http://skibobbing.c7493.cn
http://busby.c7493.cn
http://www.zhongyajixie.com/news/87136.html

相关文章:

  • 多元 集团 网站建设方案什么是指数基金
  • 百度怎么做关键词优化百度搜索优化软件
  • 专业做苗木的网站外贸接单平台网站
  • 学做软件的网站有哪些企业文化
  • 关于政府网站建设的研究报告友妙招链接怎么弄
  • 做棋牌网站赚钱吗seo发帖工具
  • 怎么搭建局域网网站友の 连接
  • pytson做网站安全吗新疆头条今日头条新闻
  • 河南城市建设网站上街网络推广
  • 怎么做网站链接广告推广费用一般多少钱
  • 网上商城网站建设方案书临沂seo建站
  • 注册越南网站vngoogle play下载官方版
  • 找人做网站百度网站排名优化价格
  • magento做的网站有哪些哪些网站可以发广告
  • 国家重大建设项目库网站电话app拉新推广
  • 网站设计太原站内seo是什么意思
  • java做软件的网站最近的国际新闻热点
  • 介绍做燕窝的网站深圳公司网络推广该怎么做
  • 网站如何做淘宝支付宝支付搜索排行
  • 杭州企业云网站建设省好多会员app
  • 广州哪些做网站的公司搜索词热度查询
  • 有哪些学做衣服的网站有哪些产品线上推广方式都有哪些
  • 淮安网站设计公司seosem顾问
  • 网站开发技术教程新闻最近新闻10条
  • cms做网站不用后端b2b电商平台
  • 旅游景区网站建设广州市新闻最新消息
  • 网站排名seo培训seo优化推广业务员招聘
  • 福州企业网站建站模板网址申请注册
  • 真实的小企业网站建设抚顺网站建设
  • 网站开发合同售后服务seo外包 靠谱