debian - How do I write into a file in a new line using python? -


i trying make script write new aliases bashrc, when run scrip either writes in first line or in last line.my script simple:

with open ("/user/.bashrc","a+") f1:    f1.write(new_alias + " " + alias_command)    f1.seek(0,0)               # writes in first line , (1,0) writes in last    command = f1.read()    print command              # show me input without getting file every time 

so want create new line when want input new alias won't smudge , make unnecessary errors.

using \n easiest:

with open ("/user/.bashrc","a+") f1:    f1.write(new_alias + " " + alias_command + "\n") 

Comments