# coding:utf-8
# 短信发送整理
import openpyxl as openpaxl
import json
#wb = openpaxl.load_workbook('F:\dd\msg\\900109_2021-02-01_2021-02-28_TLBV9BAv.xlsx')
wb = openpaxl.load_workbook('F:\dd\msg\\900109_2021-01-01_2021-01-31_tobZRzbE.xlsx')
#wb = openpaxl.load_workbook('F:\dd\msg\\11.xlsx')
# get_sheet_names 获取所有的sheet页 这个有个坑 sheetnames这后面没有括号 不然就是 'list' object is not callable
sheets = wb.sheetnames
print(sheets)
# 根据名字获取指定的sheet页 get_sheet_by_name
for sheetName in sheets:
sheet = wb[sheetName]
# 获取每一行的数据
save = []
for row in list(sheet.rows):
data = {}
data['id'] = str(row[0].value)
data['phone'] = str(row[1].value)
data['y'] = str(row[2].value)
data['n'] = str(row[3].value)
data['time'] = str(row[4].value)
data['s'] = str(row[5].value)
save.append(data)
print(json.dumps(save))
版权归属:
天马
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区