当前位置:网站首页>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 值的视图

边栏推荐
猜你喜欢
![Leetcode: Sword finger offer 67 Convert string to integer [simulation + segmentation + discussion]](/img/32/16751c0a783cc3121eddfe265e2f4f.png)
Leetcode: Sword finger offer 67 Convert string to integer [simulation + segmentation + discussion]

Scons编译IMGUI

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

Pyhon的第六天

8. 表单标签

Some operations of MATLAB array

【图像检测】基于深度差分和PCANet实现SAR图像变化检测附matlab代码

CL210OpenStack操作的故障排除--章節實驗

leetcode:剑指 Offer 67. 把字符串转换成整数【模拟 + 分割 +讨论】

The second revolution of reporting tools
随机推荐
leetcode:890. Find and replace mode [two dict records set]
公众号也能带货?
Tomato learning notes-stm32 SPI introduction and Tim synchronization
Leetcode: Sword finger offer 67 Convert string to integer [simulation + segmentation + discussion]
Freshmen are worried about whether to get a low salary of more than 10000 yuan from Huawei or a high salary of more than 20000 yuan from the Internet
Circular linked list and bidirectional linked list - practice after class
Introduction to JDE object management platform and use of from
数据库全量SQL分析与审计系统性能优化之旅
12.13-12.19 summary
库里扛起了勇士对凯尔特人的第四场
【数据聚类】本专栏中涉及数据集、可视化及注意事项
Putty installation and use
数据库语法相关问题,求解一个正确语法
Imx6q pwm3 modify duty cycle
Network packet loss troubleshooting
Redis supports data structure types
Bid farewell to the charged xshell, and the free function of tabby is more powerful
Error mcrypt in php7 version of official encryption and decryption library of enterprise wechat_ module_ Open has no method defined and is discarded by PHP. The solution is to use OpenSSL
Planning and design of 1000 person medium-sized campus / enterprise network based on ENSP and firewall (with all configuration commands)
CL210OpenStack操作的故障排除--章节实验