import xml.etree.ElementTree as ET import base64 tree = ET.parse("/Users/xiaopengzhang/Downloads/qingdan/front/test.jszf") root = tree.getroot() for child in root: if child.tag == "ZBFileContent": ##print(child.text) base64_bytes = child.text.encode("ascii") sample_string_bytes = base64.b64decode(base64_bytes) with open("example.zip", "wb") as file: file.write(sample_string_bytes)