Python - write() versus writelines() and concatenated strings

前端 未结 5 1950
暖寄归人
暖寄归人 2020-11-27 10:54

So I\'m learning Python. I am going through the lessons and ran into a problem where I had to condense a great many target.write() into a single write()

5条回答
  •  囚心锁ツ
    2020-11-27 11:11

    if you just want to save and load a list try Pickle

    Pickle saving:

    with open("yourFile","wb")as file:
     pickle.dump(YourList,file)
    

    and loading:

    with open("yourFile","rb")as file:
     YourList=pickle.load(file)
    

提交回复
热议问题