Using Python to manipulate excel in the work is still quite common, because after all, do not understand Excel is a user of large data management software. This paper uses python3! Before you share, small make recommend a very good exchange treasure, inside are a group of love and learning Python's small partners, big thousands of, a variety of people have, especially like to see the atmosphere of this kind of people together to solve the problem, the group of information also uploaded a lot, all kinds of Daniel to solve the problem of small white , this Python group: 330637182 Welcome to join us in a conversation, progress together and master this Python language as early as possible.
First import two modules xlrd and XLWT,XLRD to read Excel table, XLWT is to write Excel table
At the command prompt, enter the command:
Pip Install Xlrd
Pip Install XLWT
Let's take a look at the use of these two modules
First, XLRD
1. First import the module, import xlrd
2. First write a table for the experiment, the contents of the table are as follows:
This is the basic operation, the following extension point
About the time format:
Take a look at the time that column of data, get what
[' Time ', 42993.0, ' 2017.01.12 ', 40900.0]
This is not what we want, this time format is in Excel, with January 1, 1900 as the starting time, the obtained data in days
In fact, in this module, there is a property to display the type of cell data, CType, there are several types:
CType = 1 # type 0 empty,1 string, 2 number, 3 date, 4 Boolean, 5 error
We can look at what type of this is it printed
The result is modified, but it's only temporary, and the original form has not been modified.
4. Save
Myworkbook.save (' Test.xls ') #保存
Thank you for reading, this case is more suitable for 0 basic novice
If everyone is interested, or the novice is learning python, can private me, my side will give tutorial guidance.
0 Basic White How do I use Python to make forms?