I must have skipped a page or two by accident during my PDF Tutorials on Python commands and arguments, because I somehow cannot find a way to take user input and shove it i
Try Something Like This.
#Getting Where To Save File
where = raw_input('Where Do You Want To Save Your File? ')
#Getting What To Write To File
text = raw_input('What Do You Want To Write To Your File? ')
#Actually Writing It
saveFile = open(where, 'w')
saveFile.write(text)
saveFile.close()
Use raw_input()
to take user input. Open a file using open()
and use write()
to write into a file.
something like:
fd = open(filename,"w")
input = raw_input("user input")
fd.write(input)
filename = input("filename: ")
with open(filename, "w") as f:
f.write(input())
This asks the user for a filename and opens it for writing. Then everything until the next return is written into that file. The "with... as" statement closes the file automatically.