zoukankan      html  css  js  c++  java
  • python test

    import win32com
    
    from win32com.client import Dispatch,constants
    w = win32com.client.Dispatch('Word.Application')
    w.Visible = 0
    w.DisplayAlerts = 0
    
    doc = w.Documents.Open(FileName = r'C:UsersjackDesktop	est课文.rtf')
    ##par = doc.Range(doc.Content.Start,doc.Content.End).Select
    par = doc.Range(doc.Content.Start,doc.Content.End)
    ##n = 0
    ##for each in w.ActiveDocument.Paragraphs:
    ##    if each.Words.Count == 0:
    ##        each.Range.Delete()
    ##        n += 1
    ##print("删除空行共:" + n + "行")
    
    ##doc.Paragraphs(1).Range.Delete()
    ##doc.Paragraphs(2).Range.Delete()
    ##doc.Paragraphs(3).Range.Delete()
    ##doc.Paragraphs(4).Range.Delete()
    
    w.ActiveDocument.Select()
    w.Selection.ClearFormatting()
    ##par.ParagraphFormat.Reset()
    
    ##par.Font.Name = "微软雅黑"
    ##par.Font.Size = "14"
    ##par1 = doc.Paragraphs(1).Range
    ##par2 = doc.Paragraphs(2).Range
    ##par1.Font.Size = "36"
    ##par2.Font.Size = "24"
    ##par1.ParagraphFormat.Alignment = 1
    ##par2.ParagraphFormat.Alignment = 1
    print("ok")
    doc.Close()
    w.Quit
  • 相关阅读:

    删与改

    基本操作
    名词解释
    Python内置函数(11)——complex
    Python内置函数(10)——float
    Python内置函数(9)——int
    Python内置函数(8)——bool
    Python内置函数(7)——sum
  • 原文地址:https://www.cnblogs.com/Jacklovely/p/5747869.html
Copyright © 2011-2022 走看看