import base64 # 例子 with open('captcha.png','wb') as f: f.write(base64.b64decode(img_base64)) # 传入需要解密的字符串