Home > other >  Python scripts run without any hints
Python scripts run without any hints

Time:11-17

# 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/

Def getScriptPath () :
Nowpath=OS. Path. The split (OS) path) realpath (_file_) [0]
Return nowpath

Read function # form

Def fun3_3_7_2 () :
App=win32com. Client. Dispatch (" WPS. Application ")
App. The Visible=0
App. DisplayAlerts=0
WorkBook=app. Wokbooks. 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)

# form write function

Def xieru (x1, y1) :
App=win32com. Client. Dispatch (" WPS. Application ")
App. The Visible=0
App. DisplayAlerts=0
WorkBook=app. Wokbooks. 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]

# 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_3_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 ")

CodePudding user response:

Then print it and see how each step of the execution result

CodePudding user response:

1. Excel spreadsheet is not specialized libraries to read and write? Why use the WPS interface,
2. Cell_value [x] [y]. Append (Sheet) Cells (x + 1, y + 1). The Value) the cell_value [x] [y] is two-dimensional, you define a dimensional, if haven't prompt to run the program, it didn't perform at
3. Chuli, frequently called xieru (x, y), undesirable

CodePudding user response:

My rough look at the code you have a lot of grammar mistakes, you first solve the debug, suggested that the execution of the function modules to print (" -- -- -- the first % d functions performed -- - "), to start from scratch, which functions performed not print this message and then into the internal print again, so simple of the debug can quickly positioning problem

CodePudding user response:


CodePudding user response:

Means that it can't find the corresponding path, how real path, either you switch to the corresponding path, or to use absolute paths

CodePudding user response:

Thank you for your enthusiastic help, there are so many questions

CodePudding user response:

refer to the second floor chuifengde response:
1. Excel spreadsheet is not specialized libraries to read and write? Why use the WPS interface,
2. Cell_value [x] [y]. Append (Sheet) Cells (x + 1, y + 1). The Value) the cell_value [x] [y] is two-dimensional, you define a dimensional, if haven't prompt to run the program, it didn't perform at
3. Chuli, frequently called xieru (x, y), undesirable

Need to define a cells_value=https://bbs.csdn.net/topics/[[0] * n for 17 in range (1001)]?

CodePudding user response:

refer to the second floor chuifengde response:
1. Excel spreadsheet is not specialized libraries to read and write? Why use the WPS interface,
2. Cell_value [x] [y]. Append (Sheet) Cells (x + 1, y + 1). The Value) the cell_value [x] [y] is two-dimensional, you define a dimensional, if haven't prompt to run the program, it didn't perform at
3. Chuli, frequently called xieru (x, y), undesirable

Cells_value=https://bbs.csdn.net/topics/[[0 for I in range (17)] for I in range (1001)]
  • Related