Difference between python2 series and python3 series dict.keys ()

Personal notes

dict.keys () in python2 series

In [25]: D = dict(a=1,b=2,c=3)

In [26]: D.keys()
Out[26]: ['a', 'c', 'b']

The list is returned normally. So it can be used as an iterator as it is

In [27]: for key in D.keys(): print "key:{}, value:{}".format(key, D[key])
key:a, value:1
key:c, value:3
key:b, value:2

dict.keys () in python3 series

In [3]: D = dict(a=1,b=2,c=3)

In [4]: D
Out[4]: {'b': 2, 'c': 3, 'a': 1}

In [5]: D.keys()
Out[5]: dict_keys(['b', 'c', 'a'])

It's not a list, but an object called dict_keys!

Recommended Posts

Difference between python2 series and python3 series dict.keys ()
Difference between Ruby and Python split
Difference between java and python (memo)
Difference between list () and [] in Python
Difference between == and is in python
[Python] Difference between function and method
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
Difference between PHP and Python finally and exit
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
[Python] Difference between class method and static method
[Python Iroha] Difference between List and Tuple
[python] Difference between rand and randn output
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
Difference between process and job
Python 2 series and 3 series (Anaconda edition)
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Difference between regression and classification
Difference between np.array and np.arange
Difference between MicroPython and CPython
Difference between ps a and ps -a
Difference between return and print-Python
Difference between Ruby and Python in terms of variables
Difference between return, return None, and no return description in Python
About installing Pwntools and Python2 series
Difference between SQLAlchemy filter () and filter_by ()
Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)
Memorandum (difference between csv.reader and csv.dictreader)
List concatenation method in python, difference between list.extend () and β€œ+” operator
(Note) Difference between gateway and default gateway
Cooperation between python module and API
Differences between Python, stftime and strptime
Difference between sort and sorted (memorial)
Difference between SQLAlchemy flush () and commit ()
Difference in how to write if statement between ruby ​​and python
Transcendental simple and clear! !! Difference between single quotes and double quotes in Python
Python / Numpy> Link> Difference between numpy.random and random.random> thread-safe or not
File open function in Python3 (difference between open and codecs.open and speed comparison)
Communicate between Elixir and Python with gRPC
Differences in authenticity between Python and JavaScript
[Python] What is pandas Series and DataFrame?
Differences between Ruby and Python in scope
[Xg boost] Difference between softmax and softprob
[Django ORM] Difference between values () and only ()
Differences in syntax between Python and Java
Difference between linear regression, Ridge regression and Lasso regression
Difference between docker-compose env_file and .env file
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
speed difference between wsgi, Bottle and Flask
Easy introduction of python3 series and OpenCV3
Differences in multithreading between Python and Jython
Differences between Ruby and Python (basic syntax)
Difference between numpy.ndarray and list (dimension, size)
Correspondence between Python built-in functions and Rust
Difference between ls -l and cat command
Exchange encrypted data between Python and C #
Difference and compatibility verification between keras and tf.keras # 1