2016-03-21 44 views
0

Sözlük bir dosyaya depolamaya çalışıyorum.Neden her zaman bu cPickle hatasını alıyorum?

Bu benim kod parçasıdır:

Accounts={} 
if username not in Accounts: 
    Accounts[username]=password 
    database=open("my_mail_database", "w") 
    pickle.dump(Accounts, database) 
    database.close() 

Ve hep bu hatayı alıyorum:

Traceback (most recent call last): 
File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ 
return self.func(*args) 
File "C:\Python34\python 3.4\my_gmail2.pyw", line 51, in submit_account 
pickle.dump(Accounts, database) 
TypeError: must be str, not bytes 

birisi bana söyleyebilir whats my koduyla sorun?

+5

http://stackoverflow.com/questions/13906623/using-pickle-dump-typeerror-must-be-str- wb dosyayı açmak zorunda değil-bayt – zezollo

cevap

1

o deneyin:

Accounts={} 
if username not in Accounts: 
    Accounts[username]=password 
    database=open("my_mail_database", "wb") 
    pickle.dump(Accounts, database) 
    database.close() 

Sen

İlgili konular