Python读写Excel文件和正则表达式

Python 读写Excel文件

这里使用的是 xlwtxlrd 这两个excel读写库。

#_*_ coding:utf-8 _*_
#__author__='观海云不远'
#__date__ = '2019-07-11'
#读写excel import xlwt
import xlrd
import re workbook = xlrd.open_workbook('data.xlsx')
sheet = workbook.sheet_by_index(0) data = [] for rx in range(0, sheet.nrows):
row = sheet.row(rx)
item = []
for cx in row:
item.append(cx)
data.append(item) workbook = xlwt.Workbook()
sheet = workbook.add_sheet('output') rIndex = 0
for row in iter(data):
cIndex = 0
for cel in row:
sheet.write(rIndex, cIndex, cel.value + " changed")
cIndex += 1
rIndex += 1 workbook.save('data_output_1.xls')

Python 正则表达式

查找val中是否存在xxx

import re
ret = bool(re.search(r'xxx', val))
上一篇:Character Sets: Migrating to utf8mb4 with pt_online_schema_change


下一篇:Jython安装步骤