Apologies in advance if I’ve formatted this incorrectly. FYI I’m only about 8 months into learning python. Here is a snippet of code:
if os.path.exists(f'{Specific_Drive_im_looking_for}') == True:
file = open(f'{Specific_Drive_im_looking_for}\config.txt','a')
file.write('nTestText')
file.close()
I want to write to a file. When I perform this snippet of code, the file is written to, but all that is written are null characters, or in another words, 9 empty spaces. The file does exist already before this snippet, and I successfully read it and close it before this.
I cannot find any information as to why exactly my file is able to be written to, but the characters themselves are not, and instead (as in this example) 9 null characters/ spaces are being written instead?
I have also tried by using:
with open (f'{Specific_Drive_im_looking_for}') as file:
which is also producing the same result.
Thank you in advance!
2