Python 3.8.5 (tags/v3.8.5:580 fbb0, 20, 2020 Jul 15:57:54) [MSC v. 1924 64 - bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
> # coding=utf-8
> The import win32com
> The from win32com. Client import Dispatch, constants
> The import OS
> The import re
> The from datetime import datetime
> Cells_value=https://bbs.csdn.net/topics/[[0 for I in range (17)] for I in range (1001)]
>
> Def getScriptPath () :
. Nowpath=OS. Path. The split (OS) path) realpath (r "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python38")) [0]
. Return nowpath
.
> Read function # form
>
> Def fun3_7_2 () :
. App=win32com. Client. Dispatch (" KWPS. Application ")
. App. The Visible=0
. App. DisplayAlerts=0
. WorkBook=app. Workbooks. Open (getScriptPath () + "\ \ Yang Lindai ditch village. XLSX")
. Sheet=WorkBook. Worksheets (" Sheet1 ")
. For the x in the range (1001) :
. For y in range (17) :
. Cell_value [x] [y]. Append (sheet) Cells (x + 1, y + 1). The Value)
. WorkBook. The Close ()
. App. The Quit ()
.
> # form write function
>
> Def xieru (x1, y1) :
. App=win32com. Client. Dispatch (" KWPS. Application ")
. App. The Visible=0
. App. DisplayAlerts=0
. WorkBook=app. Workbooks. Open (getScriptPath () + "\ \ Yang Lindai ditch village 1. XLSX")
. Sheet=WorkBook. Worksheets (" Sheet1 ")
. Sheet. The Cells (+ 1) + 1 x1, y1. Value=https://bbs.csdn.net/topics/cells_value [x1] [y1]
. WorkBook. The Close ()
. App. The Quit ()
.
> # data processing function
>
> Def chuli () :
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village, a group of. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village in two groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village in three groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village four groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town wear ditch village groups of five. *? Number, cells_value [x] [9] ") :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town wear ditch village, six groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village seven groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town wear ditch village eight groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village nine groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
. For the x in the range (1001) :
. If cells_value [x] [9].==re search (r "jiangsu province country WuTan Town ditch village 10 groups. *? ", cells_value [x] [9]) :
. For y in range (17) :
. Xieru (x, y)
.
> If __name__=="__main__" :
. Starttime=datetime. Now ()
. Fun3_7_2 ()
. Chuli ()
. Endtime=datetime. Now ()
. Total_time=(endtime - starttime). Seconds
. Print (" & gt;> Successful entry information {} article, total take {} seconds!" The format (len (cells_value), total_time))
. OS. The system (" pause ")
.
Traceback (the most recent call last) :
The File "& lt; Stdin>" , line 3, the in & lt; module>
The File "& lt; Stdin>" , line 5, in fun3_7_2
The File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python38 \ lib \ site - packages \ win32com \ client \ dynamic py", line 527, in __getattr__
Raise AttributeError (" % s % s "% (self) _username_, attr))
AttributeError: KWPS. Application. Workbooks
>