Python dict remove array to remove of del pop

  • 2020-04-02 09:47:56
  • OfStack

Such as code

Binfo = {' name ':' jay ', 'age: 20,' python ':' haha '}

Print binfo.pop('name')#pop method deletes the key and returns the value corresponding to the key

Print binfo## output: {'python': 'haha', 'age': 20}

Del binfo['python']## built-in method to delete elements

Print binfo## output: {'age': 20}

Related articles: