摘要: res = ['ab', 'bc', 'cd', 'd', 'aaa'] #index取列表中元素为d的下标*******#print(res.index('d')) #count统计列表中元素的个数*******# print(res.count('ab')) #insert在下标为2的位置插入s 阅读全文
posted @ 2019-03-13 16:47 枕上书的故事 阅读(133) 评论(0) 推荐(0) 编辑
摘要: #字符串res = 'hello,world'#判断字符串结尾的字母# print(res.endswith('w')) #查找字符串中的最右字母下标# print(res.rindex('o')) #字符串格式化(%s和format)******# result = 'my name is {na 阅读全文
posted @ 2019-03-13 16:46 枕上书的故事 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 集合集合,去重,不支持索引set1 = {1,2,3,4,5}set2 = {1,2,6,7,3,4,5}set3 = {'a','v','t','w'} update合并2个集合 set1.update(set2) print(set1) pop随机取值 print(set3.pop()) uni 阅读全文
posted @ 2019-03-13 15:33 枕上书的故事 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 布尔:True False,True就是为真,False就是为假要谨记0,None,空都为假,其余为真(空格都为真) a = 0 if a: print('ok') else:print('不ok') 引用计数和垃圾回收机制一个内存地址可以对应多个门牌号,一个门牌号只能对应一个内存地址1.在程序结束 阅读全文
posted @ 2019-03-13 15:22 枕上书的故事 阅读(504) 评论(0) 推荐(0) 编辑
摘要: 元组,是用来读取的,列表可存可取,在内存当中列表比元组占用的空间大,也支持索引取值t1 = ([1,2,3],[1,2,4],[1,2,5])# l1 = ['a','b','c']# res = t1.count('a')# res = t1.index('a')# print(res)#len: 阅读全文
posted @ 2019-03-13 15:18 枕上书的故事 阅读(169) 评论(0) 推荐(0) 编辑
摘要: python 字典类型用法info={ 'name':'唐家三少', 'age':180}info2={ 'name':'冰火魔厨' 'love':'nice'}1 popitem取出字典中最后的元素print(info.popitem())2 pop取出字中key为name的value print 阅读全文
posted @ 2019-03-13 15:07 枕上书的故事 阅读(272) 评论(0) 推荐(0) 编辑