[Tutor] creating and writing to a text file
Cameron Simpson
cs at cskk.id.au
Mon Mar 29 00:03:24 EDT 2021
On 29Mar2021 14:56, Phil <phillor9 at gmail.com> wrote:
>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?
I think you've embedded a DEL character in your programme and just can't
see it. Does your editor really show nothing odd in the 'test.txt' open
call()?
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list