----- Messaggio originale -----
> Da: "Valerio Pachera" <vale...@pbds.eu>
> A: "Tutor Python" <tutor@python.org>
> Inviato: Giovedì, 28 febbraio 2019 13:05:27
> Oggetto: Re: [Tutor] Remove soft line break

> ...
> I noticed that the end of file doesn't get preserve if I create a copy of the
> file ...

I've been told by a collegue that the when the file is opened by interpreter it 
uses the end of line of the system the program runs on.
In my case the os is linux, so python uses '\n' a end of line, no matter what's 
written in the file.
The end of line, ore better "newline" may be chosen when open the file.

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, 
closefd=True, opener=None)

So, if I have this string

s = '''
hallo, this is 
a multi line text
'''

I can save it in a text file for windows this way:

f = open('test.txt', 'w', newline='\r\n')
f.write(s)
f.close()

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to