def retry(times):def real_decorator(func):@wraps(func)def wrapper(*args, **kwargs):retried_times = 0while True:try:return func(*args, **kwargs)except Exception:retried_times += 1if retried_times > times:raisereturn wrapperreturn real_decorator