编辑代码

peilv1=float(input('输入已经下注错了的赔率:'))
peilv1jine=float(input('输入已经下注错了的金额:'))


max_roe=0
max_put1=0
max_put2=0
total_roe=0
zdsy=0
zxsy=0
zdsy2=''
zxsy2=''
a=[]
for peilv2 in range(100,1000):
    maxroe=0
    je=0
    roe=[]
    for j in range (0,1000,5):
        sy1=peilv1jine*peilv1-peilv1jine-j
        sy2=(peilv2/100)*j-peilv1jine-j
        small=int(min(sy1,sy2))
        big=int(max(sy1,sy2))
        if (sy2-sy1)!=0:
            shouyichengjihezongshouru=(sy2*sy1)/(sy2-sy1)
        else:
            shouyichengjihezongshouru=(sy2*sy1)
  
        if sy1>=0 and sy2>=0 :
            a.append([peilv2/100,j,small,big,shouyichengjihezongshouru])

# 找出所有不同的赔率值
odds = set(item[0] for item in a)

# 对于每个赔率值,筛选出盈利金额最大的项
max_profit_items = [max((item for item in a if item[0] == odd), key=lambda x: x[4]) for odd in odds]
sorted_data = sorted(max_profit_items, key=lambda x: x[0])

for x in range(0,len(sorted_data)):      
    pl=str(sorted_data[x][0])
    je=str(sorted_data[x][1]) 
    yl1=str(sorted_data[x][2])
    yl2=str(sorted_data[x][3])
    print('赔率:'+pl+'  下单金额:'+je+'  盈利金额至少为:'+yl1+'  盈利金额至多为:'+yl2)