\'\'\' 此脚本用来验证代理后台的计算是否正确 \'\'\' import openpyxl wb=openpyxl.load_workbook(r\'C:\Users\ASUS\Desktop\代理测试数据.xlsx\') #请输入测试数据地址 sheet=wb.active row_max=sheet.max_row col_max=sheet.max_column dic={} for i in range(2,row_max+1): uid=sheet[\'a\'+str(i)].value money=float(\'%2.2f\' %sheet[\'b\'+str(i)].value)*float(\'%2.2f\' %sheet[\'i\'+str(i)].value) rate1=sheet[\'c\'+str(i)].value rate2=sheet[\'d\'+str(i)].value rate3=sheet[\'e\'+str(i)].value agent1=sheet[\'f\'+str(i)].value agent2=sheet[\'g\'+str(i)].value agent3=sheet[\'h\'+str(i)].value dic.setdefault(str(agent1),0) dic.setdefault(str(agent2),0) dic.setdefault(str(agent3),0) dic[str(agent1)]+=money*(rate1-rate2) dic[str(agent2)]+=money*(rate2-rate3) dic[str(agent3)]+=money*(rate3) pass # 根据代理id查找 agent_id=input(\'输入代理id\n\') print(dic[str(agent_id)]) # 结果写入Excel wb=openpyxl.Workbook() sheet=wb.active row_i=2 sheet[\'a1\']=\'代理id\' sheet[\'b1\']=\'收益\' for j in dic.keys(): sheet[\'a\'+str(row_i)]=j sheet[\'b\'+str(row_i)]=dic[j] row_i+=1 pass wb.save(\'检验.xlsx\') input(\'检验完成\')
对应为三级代理收益
输入表格模型为
运行后即可产生结果表格Excel