I'm trying to write a script that allows a user to create a folder with any name they want, and then create a file with any name they want. Once they do they, the program asks them for 3 names and writes them into the file. I then want to allow the user to input a number from 1 to 3 and display the number of lines they want. I'm getting an error right now when trying to read the file saying something along the lines of
TypeError: invalid file: <_io.TextIOWrapper name='C:blah blah ' mode='a' encoding='cp1252'>
The code is below:
def SaveDir():
global FileSave
FileSave = filedialog.asksaveasfile(mode='a', defaultextension=".txt")
if FileSave is None:
return
print(FileSave)
SaveDir2()
def SaveDir2():
FinalFile = open(FileSave)
FinalFile.write(PRINTCONV)
FinalFile.close()