简体   繁体   English

Python Pickle append返回“ None”,而不是用户输入

[英]Python Pickle append returns “None” rather than user's input

post=input(str("Enter your post below: \n"))
addpost=pickle.dump(post, open("The Wall.txt","ab"))
print(addpost)

Have no idea why this code returns "None" rather than what is typed in... 不知道为什么此代码返回“ None”而不是键入的内容...

Because pickle.dump writes the object to the file, and returns None . 因为pickle.dump将对象写入文件,并返回None

You probably want 你可能想要

addpost = pickle.load(open("The Wall.txt", "rb"))

instead. 代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM