python--Excel-通过excel获取对应的uid和金额,进行充值

#!/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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

z千鑫

在线乞讨,行行好吧!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值