1
我想了解蟒蛇泡菜的概念。按照我所知,pickle用於將對象存儲在python中,然後我們可以在文件中訪問它們。我爲此寫了簡單的腳本,但它顯示一個錯誤。我不明白爲什麼泡菜和蟒蛇轉儲
import pickle
plist= ["one","a","two","b","End!!"]
#p={'hi','hello','hola'}
file=open("pickle.txt","w")
pickle.dump(plist, file)
file.close()
錯誤:
Traceback (most recent call last):
File "C:/Python33/pickle.py", line 1, in <module>
import pickle
File "C:/Python33\pickle.py", line 6, in <module>
pickle.dump(plist, file)
AttributeError: 'module' object has no attribute 'dump'
是的,它的工作! – user3201916
@ user3201916,如果這對你有所幫助,你可以通過[接受答案](http://meta.stackoverflow.com/a/5235)告訴社區。 – falsetru