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
Post a Comment