I am using Pycharm. First of all, whenever a module is imported into Pycharm. The complete import line disappears. But in the case of import shelve does not disappear. Also, when I run the file, I get the following errors:
Traceback (most recent call last): File "/Users/abhimanyuaryan/PycharmProjects/shelve/main.py", line 13, in <module> s = shelve.open("file.dat") File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/shelve.py", line 239, in open return DbfilenameShelf(filename, flag, protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/shelve.py", line 223, in __init__ Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/dbm/__init__.py", line 88, in open raise error[0]("db type could not be determined") dbm.error: db type could not be determined
Here is my code:
import shelve s = shelve.open("file.dat") s["first"] = (1182, 234, 632, 4560) s["second"] = {"404": "file is not present", "googling": "Google to search your content"} s[3] = ["abhilasha", "jyoti", "nirmal"] s.sync() print(s["first"]) print(s["second"]) print(s[3])
AbhimanyuAryan
source share