标签:
2、比较运算:
3、赋值运算:
4、逻辑运算:
5、成员运算:
int(整型)
"hello world"
1
2
3
|
name_list = [ ‘alex‘ , ‘seven‘ , ‘eric‘ ] 或 name_list = list ([ ‘alex‘ , ‘seven‘ , ‘eric‘ ]) |
基本操作:
1
2
3
|
ages = ( 11 , 22 , 33 , 44 , 55 ) 或 ages = tuple (( 11 , 22 , 33 , 44 , 55 )) |
1
2
3
|
person = { "name" : "mr.wu" , ‘age‘ : 18 } 或 person = dict ({ "name" : "mr.wu" , ‘age‘ : 18 }) |
常用操作:
1
2
3
|
li = [ 11 , 22 , 33 , 44 ] for item in li: print item |
1
2
3
|
li = [ 11 , 22 , 33 ] for k,v in enumerate (li, 1 ): print (k,v) |
1
2
3
4
5
6
7
8
|
print range ( 1 , 10 ) # 结果:[1, 2, 3, 4, 5, 6, 7, 8, 9] print range ( 1 , 10 , 2 ) # 结果:[1, 3, 5, 7, 9] print range ( 30 , 0 , - 2 ) # 结果:[30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2] |
一、元素分类
有如下值集合 [11,22,33,44,55,66,77,88,99,90...],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值中。
即: {‘k1‘: 大于66的所有值, ‘k2‘: 小于66的所有值}
功能要求:
1
2
3
4
5
6
|
goods = [ { "name" : "电脑" , "price" : 1999 }, { "name" : "鼠标" , "price" : 10 }, { "name" : "游艇" , "price" : 20 }, { "name" : "美女" , "price" : 998 }, ] |
五、用户交互,显示省市县三级联动的选择
1
2
3
4
5
6
7
8
9
10
11
12
13
|
dic = { "河北" : { "石家庄" : [ "鹿泉" , "藁城" , "元氏" ], "邯郸" : [ "永年" , "涉县" , "磁县" ], } "河南" : { ... } "山西" : { ... } } |
标签:
原文地址:http://www.cnblogs.com/zl-py/p/5537618.html