title: value = self.cache[key] Key error while working with Python shelve
body: <p>Here's the code:</p>
  
  <pre><code>#! python3
  # Locker
  '''Usage: Window + R: locker &lt;site&gt;
                        locker update &lt;site&gt; &lt;password&gt;
                        locker delete &lt;site&gt;
                        locker all '''
  
  import sys,shelve,pyperclip
  getPass = shelve.open('puppy')
  if sys.argv[1] != 'all':
      pyperclip.copy(getPass[sys.argv[1]])
      print('Password of',sys.argv[1],'copied to clipboard.')
  elif sys.argv[1] == 'update':
      getPass[sys.argv[2]]=sys.argv[3]
      print('Update password for',sys.argv[2],'in database.')
  elif sys.argv[1] == 'delete':
      del getPass[sys.argv[2]]
      print('Password for',sys.argv[2],'removed from database.')
  elif sys.argv[1] == 'all':
      print('Current Database:'.center(30))
      for site,key in list(getPass.items()):
          print(str(site).ljust(20,'.'),end='')
          print(key.ljust(20))
  
  getPass.close()
  </code></pre>
  
  <p>1/What it does? well, you can pretty much tell. I made a small program to save my passwords. Whenever I want to get my password for some site quickly I just need to open Run and type "locker (site)" and the password will be copied to the clipboard and I just simply paste it in the password field. Other tasks such as updating passwords or deleting password are added as well and you can see their syntax in the code. ( I did create a .bat file to make running this program easier)
  2/The problem? it throws a KeyError when I try to use the update or delete syntax and I can't figure out why:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\pminh\AppData\Local\Programs\Python\Python37-32\lib\shelve.py", line 111, in __getitem__
      value = self.cache[key]
  KeyError: 'update'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "C:\Users\pminh\AppData\Local\Programs\Python\Python37-32\locker.py", line 12, in &lt;module&gt;
      pyperclip.copy(getPass[sys.argv[1]])
    File "C:\Users\pminh\AppData\Local\Programs\Python\Python37-32\lib\shelve.py", line 113, in __getitem__
      f = BytesIO(self.dict[key.encode(self.keyencoding)])
    File "C:\Users\pminh\AppData\Local\Programs\Python\Python37-32\lib\dbm\dumb.py", line 153, in __getitem__
      pos, siz = self._index[key]     # may raise KeyError
  KeyError: b'update'
  Press any key to continue . . .
  </code></pre>