递归调用函数

 # 打开某一张图片
    def openImg(url, name, k=1):
        try:
            img = requests.get(url, headers=headers, timeout=5).content
            return saveImg(img, name)
        except Exception as e:
            print(e)
            k = k + 1
            if k > 5:
                return
            print(f'下载图片失败,再试,第{k}次下载该图片')
            openImg(url, name, k)
# 下载全部图片
    def getImgs(picList):
        for picDict in picList:
            url = picDict["src"]
            name = picDict["name"]
            openImg(url, name)
            time.sleep(2)
        print('全部图片下载完毕!')