为什么`break`在我的帖子中不起作用?

时间:2014-05-27 12:02:09

标签: python loops break

这是我的python脚本的一部分:

   with open("/tmp/IpList.txt", "r+") as f:
    for ip in f:
        page = 1
        ip = ip.strip("\r\n")
        print ip
        while True:
            url = 'http://www.bing.com/search?q=ip%3a' + ip + '&qs=n&pq=ip%3a' + ip + '&sc=0-0&sp=-1&sk=&first=' + str(page) + '&FORM=PERE'
            print url
            with open("/tmp/content.txt", "a") as out:
                content = ContentFunc()
                if "<cite>" in content and "</cite>" in content:
                    out.write(content)
                    with open("/tmp/result.txt", "a+") as result:
                        res = CiteParser()
                        result.write(res.encode('utf-8'))
                    page += 10
                else:
                    break

我将从bing网站处理我的主机。

我的break在这里不起作用。当IP完成时,它会再次读取IpList.txt的第一行......为什么?

0 个答案:

没有答案