Python Learning dictionary. Basic Three

Source: Internet
Author: User
Meta-group  A python tuple is similar to a list, except that the elements of a tuple cannot be modified.  Tuples use parentheses, and the list uses square brackets. Only one of the tuples in the tuple to be defined requires a comma followed by the element to eliminate mathematical ambiguity.  Example t= (1,) A dictionary Dictionary of each key value (Key=>value) pair is split with a colon (:), each pair is separated by a comma (,), and the entire dictionary is included in curly braces {}. The key must be unique, but the value does not have to be (only any data type can be taken, but the key must be immutable) Example: #coding =utf-8#!/usr/bin/python student={1: ' ja ', 2: ' QW ', 3: ' as '}print (student[ 1]) student[4]= ' Zxc ' #新增的键值对print (student) student[2]= ' we ' #修改字典值print (student) del student[2] #删除字典值键对print (student) Student.clear () print (student) #清除字典全部键值 del student #删除字典print (student)

Python Learning dictionary. Basic Three

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.