Created
April 2, 2017 21:47
-
-
Save romach/885015c2bfd169a89ad64f862300c1be to your computer and use it in GitHub Desktop.
Create file if not exists, throw exception in other case
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_content_to_file(content, file_path): | |
output_file = os.fdopen(os.open(file_path, os.O_CREAT | os.O_WRONLY | os.O_EXCL), "w") | |
output_file.write(content) | |
output_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment