Skip to content

Instantly share code, notes, and snippets.

@KD-MM2
Last active April 8, 2023 20:06
Show Gist options
  • Save KD-MM2/508840b0ce9a2887e41067e10f8a9dee to your computer and use it in GitHub Desktop.
Save KD-MM2/508840b0ce9a2887e41067e10f8a9dee to your computer and use it in GitHub Desktop.
decode base64 and write to file python
import os
import base64
files_size_under_1MB = {
"file_name_1": "file-1_encoded_base64",
"file_name_1": "file-2_encoded_base64"
}
for keys in files_size_under_1MB:
try: os.remove(keys) # remove the old file
except: pass
with open(keys, 'wb') as f:
f.write(base64.b64decode((files_size_under_1MB[keys])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment