How to get out of a try/except inside a while? [Python]

前端 未结 4 736
野趣味
野趣味 2021-02-14 16:12

I\'m trying this simple code, but the damn break doesn\'t work... what is wrong?

while True:
    for proxy in proxylist:
        try:
            h = urllib.urlo         


        
4条回答
  •  我在风中等你
    2021-02-14 17:11

    break is breaking the innermost loop, which is the for loop in your case. To break from more than one loop you have few options:

    1. Introduce a condition
    2. Create a sub and use return

    but in your case you actually don't need the outer while loop at all. Just remove it.

提交回复
热议问题