当前位置:网站首页>Application of list and Dict
Application of list and Dict
2022-06-12 13:07:00 【plzdonotlietome】
1. list There are several ways to expand the list ( Or the method of adding elements )
extend: Extend elements by iteratively appending


insert: Insert object before index

append: Append to the end

2. Yes ["cherry", "litchi", "strawberry", "mangosteen", "pomelo", "pineapple", "pitaya", "durian"] Default sort and sort using the third letter

3. dict Use of all methods in ( Write the source code first and then the sample )
clear(self): # real signature unknown; restored from __doc__
""" D.clear() -> None. Remove all items from D. """
Delete all items

opy(self): # real signature unknown; restored from __doc__
""" D.copy() -> a shallow copy of D """
Shallow copy

get(self, *args, **kwargs): # real signature unknown
""" Return the value for key if key is in the dictionary, else default. """
If key In the dictionary , Then return to key Value , Otherwise, return the default value

items(self): # real signature unknown; restored from __doc__
""" D.items() -> a set-like object providing a view on D's items "
A collection like object , Provides a view of the dictionary item


keys(self): # real signature unknown; restored from __doc__
""" D.keys() -> a set-like object providing a view on D's keys ""
A collection like object , Provide View on dictionary key

pop(self, k, d=None): # real signature unknown; restored from __doc__
"""
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
Delete the specified key and return the corresponding value

If key is not found, default is returned if given, otherwise KeyError is raised
If not found key, Then return to default( If a given ), Otherwise trigger KeyError


popitem(self, *args, **kwargs): # real signature unknown
"""
Remove and return a (key, value) pair as a 2-tuple.
Delete ( key 、 value ) To and as Binary return .

Pairs are returned in LIFO (last-in, first-out) order.
Press last in first out in pairs ( Last in, first out ) Sequential return
Raises KeyError if the dict is empty.
If the dictionary is empty , The cause KeyErro
setdefault(self, *args, **kwargs): # real signature unknown
"""
Insert key with a value of default if key is not in the dictionary.
If the key is not in the dictionary , Then insert the key with the default value .

Return the value for key if key is in the dictionary, else default.
""" If key In the dictionary , Then return to key Value , Otherwise, return the default value .

update(self, E=None, **F): # known special case of dict.update
"""
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
From the dictionary / Can the iteration E and F to update D


If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E Exist and have .keys() Method , For E Medium k:D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
If E Exist and lack .keys() Method , For E Medium k, v:D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
In any case , This is followed by : about F Medium k:D[k] = F[k]
values(self): # real signature unknown; restored from __doc__
""" D.values() -> an object providing a view on D's values """
In any case , This is followed by : about F Medium k:D[k] = F[k]

边栏推荐
- 嵌入式系统硬件构成-基于ARM的嵌入式开发板介绍
- Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
- Script引入CDN链接提示net::ERR_FILE_NOT_FOUND问题
- Unittest framework
- torch_geometric mini batch 的那些事
- 中科物栖CEO张磊:“芯片+OS”范式在万物互联时代的机遇与挑战|量子位·视点分享回顾...
- 成功定级腾讯T3-2,万字解析
- 2022 ARTS|Week 23
- [you code, I fix] whitesource was officially renamed mend
- When to use binary search
猜你喜欢

442 authors, 100 pages! It took Google 2 years to release the new benchmark big bench | open source

C#DBHelper_FactoryDB_GetConn

快速下载谷歌云盘大文件的5种方法

IC chip scheme fs4062b for lithium battery charging with 5V boost to 12.6V

Pre research of image scanning tool

The goods are full. You must take this knowledge

2022 ARTS|Week 23

leetcode 47. Permutations II full permutations II (medium)

Installation of pagoda

442个作者100页论文!谷歌耗时2年发布大模型新基准BIG-Bench | 开源
随机推荐
Robot Jacobian solution
Newton method for solving roots of polynomials
Successful job hopping Ali, advanced learning
Vant tab bar + pull-up loading + pull-down refresh demo van tabs + van pull refresh + van list demo
MUI登录数据库完善与AJAX异步处理【MUI+Flask+MongoDB+HBuilderX】
创新实训(十二)项目总结
Binary tree (serialization)
Summary of question brushing in leetcode sliding window
一行代码实现shell if else逻辑
Itk:: neighborhood get 6 neighborhood, 18 neighborhood, 26 neighborhood, 18/6 neighborhood, 26/18 neighborhood
基于华为云鲲鹏弹性云服务器ECS部署openGauss数据库【这次高斯不是数学家】
442个作者100页论文!谷歌耗时2年发布大模型新基准BIG-Bench | 开源
Experience and learning path of introductory deep learning and machine learning
What is the function tag? Article to understand its role and its best practices
用PyTorch进行语义分割
多源BFS问题 模板(附题)
软件构造 03 正则表达式
Overview of embedded system 3- development process, learning basis and methods of embedded system
Install MySQL database independently on Debian 10
ITK multiresolution image itk:: recursivemultiresolutionpyramidimagefilter