2018年12月31日

集合

摘要: 集合使用{}表示,它是无序的, 不能使用索引, 内部不能有重复的元素 例: {1, 2, 4, 45, 5} 支持 len()函数 支持 in 和 not in 运算符 1 in {1, 2 ,4, 6} True 1 not in {1,2,5,6} False 集合使用,例: {1,2,43,5 阅读全文

posted @ 2018-12-31 23:18 lzxanran 阅读(68) 评论(0) 推荐(0)

元组

摘要: Python将不能修改的值称为不可变的,而不可变的列表称为元组(tuple) 定义元组使用圆括号() 例: number = (90, 100, 21) 可以使用for循环来遍历元组 虽然不能修改元组的值,但可以给存储元组的变量重新赋值 阅读全文

posted @ 2018-12-31 23:08 lzxanran 阅读(78) 评论(0) 推荐(0)

列表切片

摘要: 处理列表的部分元素,称为切片 例: players = ['charles', 'martina', michael', 'florence', 'eli'] print(players[0:3]) # 取前3个元 素 print(players[:3]) # 从第一个开始,到第3个 print(p 阅读全文

posted @ 2018-12-31 22:54 lzxanran 阅读(133) 评论(0) 推荐(0)

操作列表

摘要: 列表支持嵌套列表.\ 例: list = [1, 2 ['title', 'end'], 'hello', 'word'] 1.遍历列表 使用for循环来打印列表 例: list = ['apple', 'banana', 'pear'] for list1 in list: print(list1 阅读全文

posted @ 2018-12-31 22:47 lzxanran 阅读(93) 评论(0) 推荐(0)

导航