Created
January 28, 2014 15:29
-
-
Save python-consulting/8669651 to your computer and use it in GitHub Desktop.
Python create and write file
This file contains 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 create_and_write_file(filename, data): | |
fd = open(filename, "w") | |
if not fd: | |
raise Exception("Unable to create %s. Check for read-write permissions." % filename) | |
fd.write(data) | |
fd.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment