Correct way to write line to file?

后端 未结 14 1895
日久生厌
日久生厌 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:48

    To write text in a file in the flask can be used:

    filehandle = open("text.txt", "w")
    filebuffer = ["hi","welcome","yes yes welcome"]
    filehandle.writelines(filebuffer)
    filehandle.close()
    

提交回复
热议问题