Skip to content

Instantly share code, notes, and snippets.

@wddwycc
Created June 25, 2017 08:00
Show Gist options
  • Save wddwycc/62a4ffd59cb4dd850c5aff2016d9ea11 to your computer and use it in GitHub Desktop.
Save wddwycc/62a4ffd59cb4dd850c5aff2016d9ea11 to your computer and use it in GitHub Desktop.
Python write to a path
def write(filepath, content):
folder = os.path.dirname(filepath)
if not os.path.isdir(folder):
os.makedirs(folder)
with open(filepath, 'wb') as f:
f.write(content.encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment