How to get all the keys from a dictionary in Python

Опубликовано: 28 Сентябрь 2024
на канале: Enthought
8,525
48

In this short tutorial, you will learn how to extract all the keys from a dictionary in Python, and how to use them with set operations. Want to learn more? See our Python classes at https://goo.gl/Y3H7Uz.

Read the documentation for dict views here: https://docs.python.org/3/library/std...
Read the documentation for sets here: https://docs.python.org/3/library/std...

Code from video:
*****************
employees = {1: 'michael', 2: 'eric', 3: 'michael'}
employees.keys()
employees.keys() & {2, 3}

Connect with us!
*****************
  / enthought  
  / enthought  
  / enthought