I have the path of a directory workdir
, and I would like to save a text file into it, then append text to that text file.
My code to append to the text file works fine, but I am struggling with the initial step of dropping my text file into the workdir
.
Here is my code:
workdirpath = os.path.dirname(self.finfo.local_file_path)
for file in glob(workdirpath):
with open(f"{workdir}.txt", 'w') as f:
f.write(page.text)
I'm not sure what the glob
function does but I don't think it is relavent.
The above code simply creates a file in the same working directory as the workdir
, but I want the file to be inside workdir
!