酸洗字符串时换行符和文字\ n的问题

时间:2012-10-13 18:53:20

标签: python newline pickle

postoption=input("Press 1 to leave a post, and 2 to close The Wall.")
        if postoption=="2":
            print("Wall closed.")
        elif postoption=="1":
            wally=pickle.load(open("The Wall.txt","rb"))
            usernamey=pickle.load(open("username1.txt","rb"))
            wu="\n",(wally),"\n",(usernamey)
            apost=input("Enter your post below: \n")
            pwickle=pickle.dump((wu, apost), open("The Wall.txt","wb"))
            print(pwickle)
        else:
            print("Wall closed.")

此代码将保留" \ n"而不是新行,因为它正在重新读取.txt文件中保存的内容。阻止这种情况的最简单方法是什么?

0 个答案:

没有答案