Math Python 2.7.3数学缺陷(4000万小于60万)

Math Python 2.7.3数学缺陷(4000万小于60万),math,python-2.7,Math,Python 2.7,已解决 在我的程序中,它认为4000万不到60万 代码如下: (循环20次后停止) 重新导入 导入urllib2 x=0 d=1 c=1 highestmemberid=1 最高会员现金=4301848 而(d==1): x=浮动(x+1) 如果(x==14或x==3或x==11或x==13或x==15): x=x+1 打印x, url=”http://www.marapets.com/profile.php?id=“+str(x) home=opener.open(url) matchpoin

已解决

在我的程序中,它认为4000万不到60万

代码如下: (循环20次后停止)

重新导入
导入urllib2
x=0
d=1
c=1
highestmemberid=1
最高会员现金=4301848
而(d==1):
x=浮动(x+1)
如果(x==14或x==3或x==11或x==13或x==15):
x=x+1
打印x,
url=”http://www.marapets.com/profile.php?id=“+str(x)
home=opener.open(url)
matchpoint=re.compile((*?)
home=home.read()
家
点=关于findall(匹配点,主页)
如果(”http://images.marapets.com/stuff/banned.gif“在家中”或“此用户不存在”在家中):
打印“禁止/不存在”
其他:
mp=分数[0][1]
mp=mp.replace(“mp”,“”)
mpcheck=mp.replace(“,”,“”)
mp=浮动(mpcheck)
如果(mpcheck>highestmembercash):
highestmembercash=mpcheck
highestmemberid=x
打印“更丰富”
其他:
打印“不要更富!”
打印mp
打印“marapets中最富有的玩家是玩家id:”+str(highestmemberid)+”谁拥有“+str(highestmembercash)+”MP。“
如果(x==5368561):
打印“marapets中最富有的玩家是玩家id:”+str(highestmemberid)+”谁拥有“+str(highestmembercash)+”MP。“

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

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

请将其减少为a。它现在尽可能小。@Tyranitar:你在说什么
mpcheck
是一个字符串。然后设置
mp=float(mpcheck)
。然后你比较最高的会员现金,而不是mp。我删除了那条评论。我还没想到有人看到它。您的右DSM。
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."