![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Python基础
Python基础
代码必wrong
这个作者很懒,什么都没留下…
展开
-
字典类型
#zip()函数将列表或元组的对应位置合为一体成为元组name = ["老高","小赵","小明","小花"]sex = ("男","男","女","男")dictionary = dict(zip(name,sex))tp = tuple(zip(name,sex))ls = list(zip(name,sex))print(dictionary)print(tp)print(ls)#使用键值对的方式name = ("老高","小赵","小明","小花") #只能是元组sex =原创 2020-12-17 22:29:27 · 401 阅读 · 0 评论 -
Python之列表、元组
Python--列表与元组列表元组列表一维列表空列表arr = []列表推导式import randomarr = [(random.randint()) for x in range(10)]print(arr)列表排序通常用sorted()内置函数,用list.sort()会改变原本list的顺序,使用sorted()函数赋给另一个列表arr = [1, 5, 8, 9, 2, 2, 0, 4, 6]ls = sorted(arr, reverse=True)print原创 2020-12-17 22:26:43 · 216 阅读 · 0 评论