随笔分类 -  python学习笔记

学习笔记
集合的使用
摘要:集合:无序、不重复的数据集合 作用: 1、去掉重复。把列表变成集合就去重了 2、关系测试。测试交集、差集、并集、子集、对称差集等关系 阅读全文

posted @ 2017-10-15 21:08 Alan_chow 阅读(195) 评论(0) 推荐(0)

字典的循环
摘要:字典循环的效率问题: 1 info={ 2 'stu1001':'tenglan wu', 3 'stu1002':'longze luola', 4 'stu1003':'xiaozee mali', 5 } 6 7 for i in info:#循环打印字典的key 8 print(i) 9 f 阅读全文

posted @ 2017-10-14 16:44 Alan_chow 阅读(113) 评论(0) 推荐(0)

字典的fromkeys方法的使用
摘要:fromkeys1、将列表创建为字典 2、创建的字典value等于将值拷贝了三次,实际value指向的是一个地址 a=info.fromkeys([1,2,3])#将列表创建为字典 print(a) b=dict.fromkeys([4,5,6],[1,{'name':'Alan'},678])#等于将值拷贝了三次,实际value指向的是一个地址 print(b) b[4][1]['n... 阅读全文

posted @ 2017-10-14 16:33 Alan_chow 阅读(208) 评论(0) 推荐(0)

字典的更新update方法的使用
摘要:update方法:对于字典a,通过b来更新:如果a字典中存在b字典中的key-value值,则对a进行更新,不存在的值则插入 阅读全文

posted @ 2017-10-14 16:12 Alan_chow 阅读(1150) 评论(0) 推荐(0)

简单字典操作
摘要:#字典的操作#key-value类型的数据类型 info={ 'stu1001':'tenglan wu', 'stu1002':'longze luola', 'stu1003':'xiaozee mali', } p=info.get('stu1001')#安全获取 print(p) print('stu1003'in info)#判断key是否在字典内 print(... 阅读全文

posted @ 2017-10-14 15:47 Alan_chow 阅读(327) 评论(0) 推荐(0)

字符串操作
摘要:python字符串操作的基本方法: 阅读全文

posted @ 2017-10-14 15:20 Alan_chow 阅读(156) 评论(0) 推荐(0)

循环列表练习
摘要:1 goods_list=[ 2 ('huaweiP9',3200), 3 ('Macbook',6180), 4 ('furongwang',225), 5 ('chengguangCup',85), 6 ('pythonbook',84) 7 ] 8 shopping_list=[] 9 sal 阅读全文

posted @ 2017-10-10 19:24 Alan_chow 阅读(162) 评论(0) 推荐(0)

导航