Найти - Пользователи
Полная версия: shelve непонятная ошибка
Начало » Python для новичков » shelve непонятная ошибка
1
FILLIPO
Здравствуйте! Помогите пожалуйста разобраться.

Застрял на фрагменте в учебнике:
Next, I take the idea of pickling one step further by shelving the lists together in a single file. Using the shelve module, I create a shelf that acts like a dictionary, which allows the lists to be accessed randomly.

First, I create a shelf, pickles:
print "\nShelving lists."
pickles = shelve.open("pickles2.dat")
Повторяю этот фрагмент в интерпретаторе:
import shelve 
shelve_it=shelve.open("D:\Python_programs\ordered_dump")
И получаю страшно длинную ошибку:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
shelve_it=shelve.open("D:\Python_programs\ordered_dump","c")
File "C:\Program Files\Python26\lib\shelve.py", line 234, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "C:\Program Files\Python26\lib\shelve.py", line 218, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
File "C:\Program Files\Python26\lib\anydbm.py", line 80, in open
raise error, "db type could not be determined"
error: db type could not be determined
мне понятно только
error: db type could not be determined
а все остальное - нет


объясните пожалуйста
truporez
Возможно для создания хранилища был использован один интерфейс, а при чтении происходит попытка открыть другим.
neo08
А по моему должно быть вот так
import shelve 
shelve_it=shelve.open("D:\\Python_programs\\ordered_dump")
Не ‘\’ а ‘\\’
FILLIPO
neo08, Ваш пример ведет к той же ошибке

Извините, сам заметил:
в примере
pickles = shelve.open("pickles2.dat")
а у меня расширение файла не проставлено.

после прописывания .dat ошибка ушла

Спасибо
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB