python读取excel以及python全套安装

python安装:python2于python3的语法不一样,我都不会,建议安装python3,在安装时记得添加环境变量,python的卸载也是用安装包卸载的,其他过程略

pycharm安装:开源版,装上就行

pip安装(管理扩展包之类的东西,有了这个才可以读excel):这篇亲测有效,其他的看起来都很麻烦 传送门

使用包的时候需要在pycharm中添加进去,参照这篇

excel的使用方法,这里是关于python3的,写的挺清楚的(传送门

下面是我自己写的关于python读写excel的代码:

算了太懒了

import xlwt
import xlrd
import openpyxl

name = "test.xlsx"
book = xlrd.open_workbook(name)
sheet = book.sheet_by_index(0)
n = sheet.nrows
m = sheet.ncols

newbook = openpyxl.Workbook()
newsheet = newbook.get_active_sheet()

cnt = 1;
for i in range(1, n + 1) :
    for j in range(1, m + 1) :
        newsheet.cell(cnt + i - 1, j, sheet.cell(i - 1, j - 1).value)
cnt += n;

name = "test1.xlsx"
book = xlrd.open_workbook(name)
sheet = book.sheet_by_index(0)
n = sheet.nrows
m = sheet.ncols
for i in range(1, n + 1) :
    for j in range(1, m + 1) :
        newsheet.cell(cnt + i - 1, j, sheet.cell(i - 1, j - 1).value)
cnt += n
newbook.save("test2.xlsx")
print("success")