标签:while def ISE temp exce until print tor cee
函数重做的装饰器
def retry_times(attempt): def decorator(func): def wrapper(*args, **kw): att = 0 while att < attempt: try: return func(*args, **kw) except Exception as e: print(e) time.sleep(2) att += 1 return wrapper return decorator @retry_times(3) def make_trouble(): ‘‘‘Retry until succeed‘‘‘ print (‘retrying...‘) raise if __name__ == ‘__main__‘: make_trouble()
标签:while def ISE temp exce until print tor cee
原文地址:https://www.cnblogs.com/xiao-apple36/p/12218754.html