How to append new data onto a new line

后端 未结 9 1750
一整个雨季
一整个雨季 2020-12-02 16:41

My code looks like this:

def storescores():

   hs = open(\"hst.txt\",\"a\")
   hs.write(name)
   hs.close() 

so if I run it and enter \"Ry

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 17:00

    I presume that all you are wanting is simple string concatenation:

    def storescores():
    
       hs = open("hst.txt","a")
       hs.write(name + " ")
       hs.close() 
    

    Alternatively, change the " " to "\n" for a newline.

提交回复
热议问题