#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2020/9/17
# @Name : zhouZX
# @Desc :
"""
# uid money
# 882735480 10
# 882735429 20
通过excel获取对应的uid和金额,进行充值
"""
import xlrd
import json
import requests
def tw_test_add_zuanshi(uid, diamond):
# 此处编写个人充值接口
# "uid": uid,
# "count": diamond,
if __name__ == "__main__":
# read_excel()
data = xlrd.open_workbook(r'C:\test_zzx\log\jia_zuanshi.xlsx')
sheet = data.sheet_by_name('Sheet1')
# 获取表的行数
nrows = sheet.nrows#获取行
ncols = sheet.ncols#获取列
nos = []
for i in range(1, nrows):
for j in range(ncols):
#ctype : 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error
ctype = sheet.cell(i, j).ctype#获取数据类型
v = sheet.cell(i, j).value
if ctype == 2:#2是小数,如果是小数就转整数
v = int(v)
nos.append(v)
uids = nos[0::2]#获取到对应uid
diamonds = nos[1::2]#获取到对应钻石数
dic = {}#key是uid,value是充值金额
index = 0
while index < len(uids):
dic[uids[index]] = diamonds[index]
index += 1
print(dic)
for uid,diamond in dic.items():
tw_test_add_zuanshi(uid, diamond)#传给接口
print(uid)
print(diamond)
python--Excel-通过excel获取对应的uid和金额,进行充值
最新推荐文章于 2023-08-25 16:29:41 发布