python 3.x - write to file in python3 -


i python beginner. writing file as:

   open("init", mode='w') out:      out.write(datname)      out.write("\n")      out.write("t\n")      out.write(datgroup)      out.write("\n")      out.write(datlatx)       out.write("  ") 

while working, looking bad (space , newline separate write statement).

i read page, still no idea.

is there better way of doing given out.write(datname"\n") invalid?

well, do

out.write(datname + "\n") 

but may easier use print:

print(datname, file=out) 

as print automatically appends newline.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -