Skip to content

Instantly share code, notes, and snippets.

@yuchant
Created December 8, 2012 00:59
Show Gist options
  • Select an option

  • Save yuchant/4237903 to your computer and use it in GitHub Desktop.

Select an option

Save yuchant/4237903 to your computer and use it in GitHub Desktop.
Convert file to base64. Using for fonts > b64 string.
"""
python to_base64.py some_file
"""
import sys
import os
def main(path):
with open(path) as f:
sys.stdout.write(f.read().encode('base64').replace('\n', ''))
if __name__ == "__main__":
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment