Python path and append

Seymore4Head Seymore4Head at Hotmail.invalid
Tue Apr 26 22:57:16 EDT 2016


On Tue, 26 Apr 2016 19:16:56 +0100, Michael
<bigbadmick2000 at hotmail.com> wrote:

>If you want to read an entire file, append a space and asterisk and write it to another file, this is the code you need:
>
>infile = open('win.txt', 'r')
>text = f.read()
>infile.close()
>text += " *"
>outfile = open('outfile.txt', 'w')
>outfile.write(text)
>outfile.close()
>
>If, on the other hand, you wish to read a file and append a space and asterisk TO THE END OF EVERY LINE, you require the following code:
>infile = open('win.txt', 'r')
>lines = infile.readlines()
>infile.close()
>outfile = open('outfile.txt', 'w')
>for line in lines:
>    line = line.strip() + " *\n"
>    outfile.write(line)
>outfile.close()
>
>Hope that helps!
>
>BigBadMick
>bigbadmick2000 at hotmail.com 		 	   		  

I will have a look at this.
Thanks



More information about the Python-list mailing list