access数据类型百度百科_Day 7 基本数据类型
一 列表補充 Lists
需要掌握的其它命令
index
Returns the index of the first element with the specified value
count
Returns the number of elements with the specified value
extend
Add the elements of a list (or any iterable), to the end of the current list
reverse
Reverses the order of the list
sort
Sorts the list
二 元組 Tuples
1.定義 Definition
Tuples are written with round brackets, elements in tuples are separated by commas
Notice that you should add a comma in the brackets if there is only one element in a tuple
A tuple is a collection which is ordered and unchangeable.
2.作用 Usage
Tuples are used to store multiple items in a single variable.
3.優先掌握的操作
Similar to the previous list
三 字典 Dictionary
1.定義 Definition
A dictionary is a collection which is unordered, changeable and does not allow duplicates.
Dictionaries are written with curly brackets, and have keys and values,and can be referred to by using the key name.
2.作用 Usage
Dictionaries are used to store data values in key:value pairs.
3.特點 Characteristic
Changeable
可變類型
Unordered
無序
Duplicates Not Allowed
Dictionaries cannot have two items with the same key:
4.數據轉化 Convert
可以將含有嵌套的部分列表轉為字典
5.需要掌握的操作
取值 Access items
You can access the items of a dictionary by referring to its key name, inside square brackets:
The keys() method will return a list of all the keys in the dictionary
通過get取值 Access items by "get"
This method is similar to the previous one, but if the key you input were not in the dictionary, it could return the value "None"
Update
Updates the dictionary with the specified key-value pairs
Setdefault
Returns the value of the specified key. If the key does not exist: insert the key, with the specified value
補充了解
1.深淺拷貝
Shallow copy and Deep copy
# from copy import deepcopy
import copy
?
l = [11, 22, [111, 222]]
new_l = l.copy()
new2_l = copy.deepcopy(l)
l[2][0] = 333
# 改變原列表的字列表中的一個值,觀察新列表的變化
print("原列表", l)
# 淺拷貝得到的列表會隨著原列表而改變
print("淺拷貝新列表", new_l)
# 而深拷貝得到的列表不會改變
print("深拷貝新列表", new2_l)
2.列表為什么沒有find命令
3.hash
A hash is a function that converts one value to another. Hashing data is a common practice in computer science and is used for several different purposes. Examples include cryptography, compression, checksum generation, and data indexing.
Hash算法可以將一個數據轉換為一個標志,這個標志和源數據的每一個字節都有十分緊密的關系。Hash算法還具有一個特點,就是很難找到逆向規律。
具體請見百度百科:
總結
以上是生活随笔為你收集整理的access数据类型百度百科_Day 7 基本数据类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 清空所有对象_学习pyth
- 下一篇: ambari hdfs 启动报错_HDF