[Tutor] creating and writing to a text file

Phil phillor9 at gmail.com
Sun Mar 28 23:56:26 EDT 2021


Thank you for reading this.

This is a simple task that I've carried out many times in the past but 
for some reason I've failed this time.

I've saved the following code as "file_test.py"

with open('test.txt', 'w+') as f:
     f.write('testing')

Entering "python3 file_test.py" creates the following directory entry:

'test'$'\177''.txt'

If I open and then read "'test'$'\177''.txt'" the file it does contain 
"testing".

Why isn't the created file named test.txt?

Python 3.8 running under Linux.

-- 
Regards,
Phil



More information about the Tutor mailing list