Python installation:
1. Download the windows installation version in the download on the official website https://www.python.org/
After following the instructions, enter python at the command line to start python programming.
Open hello world
I like to program in the text, so I created a hello.py text and programmed in it:
print("Hello, World!")
Run this file, locate this directory on the command line and enter python hello.py to get the command line response:
Hello, World!
At this point python is installed.
Load third-party libraries
Reading excel is a library that uses python: xlrd
This library is installed directly on the windows command line:
pip install xlrd
After installation, you can use the xlrd function library
Read excel file
We call this library in the hello.py we used earlier
# The meanings of the symbols are: back row are comments Import xlrd # Import xlrd library Bok = xlrd.open_workbook (R & lt ' E: \ temp \ xxxx.xlsx ' ) # reads E: \ temp \ xxxx.xlsx this excel file = SHT bok.sheets () [0] # SHT is table 1 ROW1 = sht.row_values (1 ) # ROW1 is the first row in table 1 Print (ROW1) # print the first row of all data cell44 = sht.cell ( 3, 3 ) .Value # cell44 is the fourth ranked fourth element Print (cell44) # print it print("Hello, World!") #打印hello world
the above