#!/usr/bin/python
#-*- coding: utf-8 -*-
#python数据类型有:数,字符串,列表(lis),元组(tuple),集合,字典。下面分别是实例
#列表
OSType = ["linux","windows","unix","mac"]
for i in students:
print i,
#元组用()定义,与列表的区别:元组不能修改值
#python交换两个值的方式
students[0],students[3] = students[3],students[0]
print students
#集合set(元素)
a = set("abcnmaaaaggsng")
b = set("cdfm")
#交集
x = a&b
print x
#并
y = a | b
print y
#差集
z = a - b
print b
#消除重复元素
new = set(a)
print new
#字典
Information = {'name':'weiwei','home':'guilin','like':'music'}
#使用字典
print Information['name']
Information["hoby"] = "quanji"
print Information
转载于:https://my.oschina.net/yanxiaoshuai/blog/470918