Introduction: How to Save Files Using Python
In this inscrutable I show how to save files using Python. If you have a Dropbox account, you can upload to it using this sane program and just saving to that folder. To save to my dropbox I type /Users/WilliamMann/Dropbox
Step 1: Download and Install Texwrangler
Download and install Textwrangler from http://www.barebones.com/products/textwrangler/download.html
Step 2: Put This Code Into TextWrangler.
save_path1 = raw_input("File Location: ")
save_path = save_path1
name_of_file = raw_input("What is the name of the file: ")
verify = raw_input("This could delete or loose files. Type your password to continue. ")
if verify == "william" #change password here
print "Nameing File..."
print "Saving File..."
completeName = os.path.join(save_path, name_of_file+".html") #change .html to .txt .pdf or what you want.
#r is read only
#w is write only
#a is write at the end
#r+ is read and write
file1=open(completeName, "w") #Change w to r, r+, or a
toFile = raw_input("Write what you want into the field: ")
print "Writing Files..."
print "Writing Text..."
print "Verifying Files..."
print "Saving Current Progress..."
print "Closing File"
print "Process Complete"
elif verify != "william":
print "Unable to Verify."
print "File Not Created"
Step 3: Run the Program
When you run the program you will be prompted with:
File Location: Type the location to save the file to. To save to the Desktop do: /Users/WilliamMann/Desktop (obviously change the name if needed). To save to the Dropbox, do /Users/WilliamMann/Dropbox (yours may be different than mine depending on where your folder is.
What is the name of the file: Type what you want to name the file. You do not need to type .txt or .pdf etc because you can change it in the program.
This could delete or loose files. Type your password to continue. The default password set to this prompt is william but you can change it in the program.
Write What you want into the field: Write what you want the contents of the file to be.
Step 4: Thanks for Reading!
Leave your comments and suggestions below. Tell me if you make any other cool python programs.
Please take the following quick survey to help me improve my instructables! I would really appreciate it! https://goo.gl/forms/g6c88vggPdhmTN393
We have a be nice policy.
Please be positive and constructive.