After the study of the list, the meta-group was studied. Tuples and lists function similarly, but tuples cannot be modified, so tuples are called read-only lists.
The following is a list of string operations:
Name.capitalize () #首字母大写
Name.count ("a") #数列表中有几个a
Name.center (5o, "-") #意思是一共打印50个字符, not enough to "-" fill
Name.endwith ("ex") #看字符串是否以ex结尾
Name.expandtabs (tabsize=30) #将tab键转换成30个空格
The following is a dictionary:
In dictionaries that are not indexed by location, the dictionary is unordered because it has no subscript and the dictionary does not need subscript because it has a key
info={
' stu1101 ' = "A"
' stu1102 ' = "B"
' stu1103 ' = "C"
}
Print (info)
(1) Check
Act 1): Print (info["stu1101"]) #通过键查找
Act 2): Print (Info.get (' stu1103 '))
(2) Change
info["stu1101"]= "WU"
(3) Increase
info["stu1104"]= "C"
(4) by deleting
1) FA 1:del info["stu1101"]
2) FA 2:info.pop ("stu1101")
#判断一个字典中有没有
Print (' stu1104 ' in info)
#多级字典的嵌套
catalog={
" "={
"Key": [List]
}
‘
" "={
}
}
Info.value () #打印值
Info.key () #打印键
Python Learning Comprehension Section 3rd