Python Learning Comprehension Section 3rd

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.