import pickle

with open("school_info","wb") as school:
user_input = str(input("请输入学校的名字:"))
if len(user_input.strip()) > 0:
pickle.dump(user_input,school)

上面是pickle的dump方法

with open("school_info","rb") as school:
data1 = pickle.load(school)
print(data1)

这是pickle的load方法

05-11 16:12