-1

解决了

在我的程序中,它认为 4000 万小于 600,000。

这是代码:(循环20次后停止)

import re
import urllib2
x = 0
d = 1
c = 1
highestmemberid = 1
highestmembercash = 4301848
while (d==1):
    x = float(x + 1)
    if (x==14 or x==3 or x==11 or x==13 or x==15):
        x = x + 1
    print x,
    url = "http://www.marapets.com/profile.php?id=" + str(x)
    home = opener.open(url)
    matchpoint = re.compile("<td align='left' valign=middle><B style='color:#(......);'>(.*?)</B></td>")
    home = home.read()
    home = home
    points = re.findall(matchpoint,home)
    if ("http://images.marapets.com/stuff/banned.gif" in home or  "This user does not exist" in home):
        print "banned/dosen't exist"
    else:
        mp = points[0][1]
        mp = mp.replace(" MP","")
        mpcheck= mp.replace(",","")
        mp = float(mpcheck)
        if (mpcheck > highestmembercash):
            highestmembercash = mpcheck
            highestmemberid = x
            print "richer"
        else:
            print "Not richer!"
        print mp
        print "The richest player in marapets is player id #: " + str(highestmemberid) + "Who has: " + str(highestmembercash) + " MP."
    if(x == 5368561):
        print "The richest player in marapets is player id #: " + str(highestmemberid) + "Who has: " + str(highestmembercash) + " MP."

该程序所做的是从页面中获取现金金额,然后查看这是否是最高金额。它循环了大约 500 万次。

4

1 回答 1

2

mpcheck是一个字符串,您要检查mp > highestmembercash并分配highestmembercash = mp.

于 2013-07-07T21:25:35.400 回答