元组tuple
#只能初次赋值,不能更改和删除
#支持切片
>>> a
(1, 2, 3, 4, 5, 6, 7, 8, 9)
>>> a [0:6:2]
(1, 3, 5)
type((1,))#tuple
type((1)) # int
元组可做格式化输出
>>> print ‘这个数%f‘ % (5)
这个数5.000000
>>> print ‘整数%d‘ % (5)
整数5
>>> print ‘字符%s‘ % (‘abc‘)
字符abc
字典
>>> zidian={‘April‘:‘student‘, ‘wu‘:‘teacher‘}
>>>
>>> for k, v in zidian.items():
... print ‘key:%s value:%s‘ % (k,v)
...
key:April value:student
key:wu value:teacher
.keys
.values #dic[key]
>>> zidian
{‘April‘: ‘student‘, ‘wu‘: ‘teacher‘}
>>> zidian[‘zhang‘] = ‘teacher‘ #字典可赋值
>>> zidian
{‘April‘: ‘student‘, ‘wu‘: ‘teacher‘, ‘zhang‘: ‘teacher‘}
>>> zidian[‘zhang‘] = ‘mysql‘ #字典的值可更改
>>> zidian
{‘April‘: ‘student‘, ‘wu‘: ‘teacher‘, ‘zhang‘: ‘mysql‘}
>>>
>>> del zidian[‘zhang‘] #字典的值可删除
>>> zidian
{‘April‘: ‘student‘, ‘wu‘: ‘teacher‘}
>>> for i in zidian.keys():
... print i
...
April
wu
>>> for i in zidian.values():
... print i
...
student
teacher