Detailed explanation of the use of dictionary dict in Python

黄舟
Release: 2017-07-26 15:47:54
Original
1391 people have browsed it

This article mainly introduces the simple definition of Python and the method of using dictionaries. It analyzes the principles, composition, definition and usage of Python dictionaries in the form of simple examples. Friends in need can refer to the examples in this article.

Describes how to simply define and use dictionaries in Python. Share it with everyone for your reference, the details are as follows:


#coding=utf8
print '''''
Python中的字典映射数据类型是由键值对构成。
python中字典一般以数字或者字符串作为键。
Python中字典的值可以是任意类型的Python对象,字典元素用大括号{}包裹。
'''
dicDefine={
  'Name':'ewang',
  'Age': 28,
  'Sex': 'famale',
  'BirthDay':'1998/09/1'
  }
print 'The content of dicDefind',dicDefine
print 'The keys of dicDefind',dicDefine.keys( )
print 'The values of dicDefind',dicDefine.values()
print 'The items of dicDefind',dicDefine.items()
Copy after login

Running results:

The above is the detailed content of Detailed explanation of the use of dictionary dict in Python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template