Created
June 25, 2017 08:00
-
-
Save wddwycc/62a4ffd59cb4dd850c5aff2016d9ea11 to your computer and use it in GitHub Desktop.
Python write to a path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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