#文件读写操作 import pickle usingData = {"Name":"xiaoming","age":80,"House":["China","Beijing","There"]} save_file=open("testfiles/file_2_2.txt","wb") pickle.dump(usingData,save_file) save_file.close() 如果出现报错: TypeError: file must have a 'write' attribute 原因可能是pickle.dump(usingData,save_file)的两个参数写反了。