一  python列表

python基础知识(六)-python数据结构

python基础知识(六)-python数据结构

a=[1,2,3,4] 

print(a.pop())#输出4

二 遍历技巧

在字典中遍历时,关键字和对应的值可以使用 items() 方法同时解读出来:

book={1:'西游记','2':'水浒传'}
for x,y in book.items():

    print(x,y)#输出1 西游记 2 水浒传

同时遍历两个或更多的序列,可以使用 zip() 组合:

questions=['name','birthday','favorite food']
responds=['张三','2000-1-1','苹果']
for x,v in zip(questions,responds):

    print(x,v)

(待更新)


相关文章: