1file = open("text.txt", "w")
2file.write("Your text goes here")
3file.close()
4'r' open for reading (default)
5'w' open for writing, truncating the file first
6'x' open for exclusive creation, failing if the file already exists
7'a' open for writing, appending to the end of the file if it exists
1Simple way to get a directory of a file and open it:
2
3from tkinter.filedialog import askopenfilename
4
5filename = askopenfilename()