Skip to content

Instantly share code, notes, and snippets.

@python-consulting
Created January 28, 2014 15:29
Show Gist options
  • Save python-consulting/8669651 to your computer and use it in GitHub Desktop.
Save python-consulting/8669651 to your computer and use it in GitHub Desktop.
Python create and write file
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