Skip to content

Instantly share code, notes, and snippets.

@yuyosy
Created January 5, 2021 18:19
Show Gist options
  • Save yuyosy/047c54b01299b25182a13e0c2c3d936a to your computer and use it in GitHub Desktop.
Save yuyosy/047c54b01299b25182a13e0c2c3d936a to your computer and use it in GitHub Desktop.
import base64
import os
import sys
def file_to_basestr(file_path):
with open(file_path, "rb") as f:
return base64.b85encode(f.read())
if __name__ == "__main__":
args = sys.argv
path = input('Path> ') if len(args) == 1 else args[1]
s = file_to_basestr(path)
with open(os.path.join(os.path.dirname(path), 'data.txt'), mode='wb') as f:
f.write(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment