我在 Python 3.5 中产生了这个错误:
回溯(最近一次调用):文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py”,第 111 行,在 __getitem__ value = self.cache[key] KeyError: ' P4_蔬菜'
在处理上述异常的过程中,又发生了一个异常:
回溯(最近一次调用):文件“C:\Users\Owner\Documents\Python\Allotment\allotment.py”,第 217 行,在 main_program() 文件“C:\Users\Owner\Documents\Python\Allotment\ allotment.py", line 195, in main_program main_program() 文件 "C:\Users\Owner\Documents\Python\Allotment\allotment.py", line 49, in main_program print("Plot 4 - ", s["P4_vegetables "]) 文件 "C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py",第 113 行,在 __getitem__ f = BytesIO(self.dict[key.encode(self.keyencoding) ]) 文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\dbm\dumb.py”,第 141 行,在 __getitem__ pos, siz = self._index[key] # 可能会引发 KeyError KeyError : b'P4_vegetables'