作者: 艾文,计算机硕士学位,企业内训讲师和金牌面试官,公司资深算法专家,现就职BAT一线大厂。
邮箱: 1121025745@qq.com
博客:https://wenjie.blog.csdn.net/
内容:跟艾文学编程《零基础入门学Python》
list 是一种有序的集合,可以随时的添加、删除一个元素
创建一个list,只有逗号分割不同的数据,然后使用方括号扩起来。list 中的元素可以是不同的数据类型




我们希望被添加到list 中的数据,每个元素做为添加对象.

注意:
list 集合 extend 和 append 的区别


再次强调: extend 、append 的区别


上边的内容不满足我们的业务需求,我们更佳希望是按照数量进行排序


这块代码有哪些可以进一步优化的呢?
1.一个简单的顾虑操作,5行代码才完成此功能
2.更佳简单、效果可视化感觉最好的方式处理?

tuple 和 list 非常类似,但是有区别


tuple 不可变,不能修改,和list 的区别

不能删除,tuple 不能变



是一个无序不重复的元素的集合。基本功能: 消除重复数据、关系测试。 set和dict 类似,但是set 不存在value

| Add an element to a set. |
| This has no effect if the element is already present.

| Remove first occurrence of value. |
| Raises ValueError if the value is not present.

| Return the union of sets as a new set. |
| (i.e. all elements that are in either set.)

| Return the intersection of two sets as a new set. |
| (i.e. all elements that are in both sets.)

| Return the difference of two or more sets as a new set. |
| (i.e. all elements that are in this set but not the others.)

字典是一种可变容器模型,可以存储任意类型对象。
语法: _dict = {key1:value1,key2:value2}





可以使用列表推导式来解决该问题。



还有没有更加简单的方法呢?


最后,让我们一起加油!!!