开发者

python urllib.request.urlopen recursion fail

开发者 https://www.devze.com 2023-02-14 13:27 出处:网络
so i have the code def constructGraph(self,url,doit=5): if doit!=0: m = urllib.request.urlopen(url) 开发者_如何学Cprint(\'test\')

so i have the code

def constructGraph(self,url,doit=5):
    if doit!=0:
        m = urllib.request.urlopen(url)
    开发者_如何学C    print('test')
        self.constructGraph('http://example.com',doit-1)

but then when I run it, it only runs the first m = urllib.request.urlopen(url) and only prints test once even though it supposed to do it twice...

and when i run the debugger, it wouldn’t even go to the print('test') line on the second recursion and would just exit

what did i do wrong?

i'm using python 3


Perhaps you can only have one request open at a time. Try putting a print statement before the urlopen call.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号