摘要: 1、创建元祖对象 把序列转化为元组。tuple(a) 注意:元组不可以修改。可切片。 a = [1,2,3,4] b=tuple(a) 结果: (1,2,3,4) 再注意: 单个元素作为元组时,这样创建: b = (1,) 验证:type(b) 结果: <class 'tuple'> 阅读全文
posted @ 2021-04-21 17:00 CiscoLee 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 1、列表的排序 a = [1,2,3,4,9,7,6,5,8] a.sort() #默认升序排列,对象不变,元素排序 a.sort(reverse=True) #降序排序 import random #打乱,随机排序 random.shuffle(a) 用法二、 a = sorted(a) #默认升 阅读全文
posted @ 2021-04-21 16:25 CiscoLee 阅读(115) 评论(0) 推荐(0) 编辑