一、参考链接
https://openpyxl.readthedocs.io/en/stable/usage.html
二、写入excel文件
from openpyxl import Workbook, load_workbook
from openpyxl.worksheet.worksheet import Worksheet
class TestExcel():
def test_write(self):
wb= Workbook()
ws=wb.active
ws.title='pysheet'
for i in range(1,10):
ws.append([f'username{i}',f'password{i}'])
wb.save('./data.xlsx')
三、读取文件
def test_read(self):
wb=load_workbook('./data.xlsx')
ws:Worksheet=wb['pysheet']
for row in ws.values:
print(row)