Aug-21-2019, 11:26 AM
Is there a reason you open file with "a+" if you only want to write to it?
To write to the dir where the .py file was started use first line.
To handle reading/writing files use "with" command.
To create output to write to file use f-strings (available since Python 3.6)
To write to the dir where the .py file was started use first line.
To handle reading/writing files use "with" command.
To create output to write to file use f-strings (available since Python 3.6)
local_dir = os.path.dirname(__file__) with open(os.path.join(local_dir, "guru99.txt"), "w") as file: for data in listeTableLoc35R: file.write(f'{data[0]}\n')