python 的异常处理 循环
PHPz
PHPz 2017-04-17 17:40:38
0
3
294
try:
  语句A
except xxx:
  语句A

要是再出现异常怎么循环下去?

PHPz
PHPz

学习是最好的投资!

reply all(3)
黄舟

Try again in except.

try:
    语句A
except Exception as e:
    try:
        语句A
    except Exception as e:
        # 继续

But this is stupid. If you really want to implement an infinite loop to catch exceptions, write like this:

def func():
    try:
        语句A
    except Exception as e:
        return False
    else:
        return True
        
while not func():
    pass    # Or do something
洪涛

According to the way you write it, the error should be ignored and statement A should be executed?
Written specifically by yourself.

循环:
    try:
       语句A
    except:
       pass  #这是忽略错误
    
左手右手慢动作

Why is there such a strange demand? You should consider changing the direction. This is obviously an endless loop

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!