Correct way to write line to file?

后端 未结 14 1918
日久生厌
日久生厌 2020-11-21 06:27

I\'m used to doing print >>f, \"hi there\"

However, it seems that print >> is getting deprecated. What is the recommended way t

14条回答
  •  长发绾君心
    2020-11-21 06:43

    I do not think there is a "correct" way.

    I would use:

    with open ('myfile', 'a') as f: f.write ('hi there\n')
    

    In memoriam Tim Toady.

提交回复
热议问题