python - new line from a text file -


i have file example.txt in format:

a,b,c,d 

and want convert to:

a b c d 

i wrote not work:

with open('newline.txt', 'w') f:      f.write (file("example.txt", "r").read().replace(",", "\n")) 

you well:

with open('newline.txt', 'w') f:       f.writelines (w + '\n' w in open("example.txt").read().split(",")) 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -