forked from 521xueweihan/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhow_for_two_list.py
More file actions
39 lines (29 loc) · 772 Bytes
/
how_for_two_list.py
File metadata and controls
39 lines (29 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#coding:utf-8
#################
# for循环两个列表的过程
list1 = ['1', '1']
list2 = ['A','B']
for x in list1, list2:
reslut = x[:]
print reslut # type=list
print "---------"
print list1, list2
print "#############"
# 简单版
dir = {'A': 'a',
'B': 'b'}
xq = dir.keys()
yw = dir.values()
# 这段代码是遍历两个列表之后赋值给新的两个列表
for i in xq, yw:
answer, question = i[:] # 这里可以加代码对元素操作之后再赋值给新的列表
print answer, ",", question # 你可以把这句放在for循环外面在看下结果
print "---------"
# 复杂版
for j in xq:
answer_ = j[:]
print answer_, ",",
print "\n"
for k in yw:
question_ = k[:]
print question_, ",",