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