当前位置:网站首页>Pyhon的第四天
Pyhon的第四天
2022-06-12 07:01:00 【cxy003344】
1. list列表扩展的方式有几种(或者说添加元素的方法)
append(self, object, /) 在末尾添加对象
insert(self, index, object, /) 将对象插入列表

extend(self, iterable, /) 扩展列表

2. 对["cherry", "litchi", "strawberry", "mangosteen", "pomelo", "pineapple", "pitaya", "durian"]进行默认排序

对上面的列表使用第三个字母进行排序

3. dict中所有方法的使用(先写源代码再写样例)
(1)clear(...)删除所有元素
D.clear() -> None
.从 D 中删除所有项目。

(2)copy(...) 拷贝
D.copy() -> a shallow copy of D
D.copy() -> D 的浅层副本

(3)fromkeys(*args, **kwargs)
Create a new dictionary with keys from iterable and values set to value
创建一个新字典,其中包含可迭代的键并将值设置为值

(4)items(...)
D.items() -> a set-like object providing a view on D's items
一个类似集合的对象,提供 D 项的视图

(5)-keys(...)
D.keys() -> a set-like object providing a view on D's keys
一个类似集合的对象,提供 D 键的视图

(6)get(self, key, default=None, /)|







(10)update(self,E=None,**F):
D.update([E,]**F)->None.Update D from dict/iterable E and F.
从字典/可迭代 E 和 F 更新 D。
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
如果 E 存在并且具有 .keys() 方法,则对于 E 中的 k:D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
如果 E 存在并且缺少 .keys() 方法,则对于 E 中的 k, v:D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
在任何一种情况下,这后面跟着:对于F中的k:D[k] = F[k]

D.values() ->一个对象,提供 D 值的视图

边栏推荐
猜你喜欢

Troubleshooting of cl210openstack operation -- Chapter experiment

Meituan won the first place in fewclue in the small sample learning list! Prompt learning+ self training practice
![[image detection] SAR image change detection based on depth difference and pcanet with matlab code](/img/c7/05bfa88ef1a4a38394b81755966e46.png)
[image detection] SAR image change detection based on depth difference and pcanet with matlab code

推荐17个提升开发效率的“轮子”

leetcode:剑指 Offer 63. 股票的最大利润【记录前缀最小和 or 无脑线段树】

(14)Blender源码分析之闪屏窗口显示软件版本号

RT thread studio learning (IX) TF Card File System

1. Foundation of MySQL database (1- installation and basic operation)

SQL Server 2019 installation error. How to solve it
![[Li Kou] curriculum series](/img/eb/c46a6b080224a71367d61f512326fd.jpg)
[Li Kou] curriculum series
随机推荐
VSCode常用插件
5 statement
leetcode. 39 --- combined sum
Junior high school education, less than 3k, to 30k+ monthly salary, how wonderful life is without restrictions
I met 15 people recently and found that I couldn't answer the basic question of this test
"I was laid off by a big factory"
丢掉丑陋的 toast,会动的 toast 更有趣
CL210OpenStack操作的故障排除--章节实验
SQL Server 2019 installation error. How to solve it
Apache POI import export excel file
RT thread studio learning (IX) TF Card File System
VSCode常用插件
8 IO Library
Problems encountered in learning go
Kali and programming: how to quickly build the OWASP website security test range?
Zhang Chi: is process a panacea?
Tomato learning notes -seq2seq
Tomato learning notes dvector and other basics
esp32 hosted
循环链表和双向链表—课上课后练