Summary of Python string deletions, list deletions, and dictionary deletions

Source: Internet
Author: User

One: string deletion

1, the string itself is immutable, a string definition, after he is not able to do anything, so the addition and deletion is the copy of the original string copy of the operation, the original string is the original string, it does not change itself

2, the string itself cannot be modified, but can be done by other means to achieve a seemingly modified effect, for example, slice + splicing replace () Replace, strip (), Rstrip (), Lstrip () remove the characters at both ends

Two: List Delete

1.pop (Index)

2.remove (Element)

3.del slicing

4.clear () empty list

Three: Dictionary Delete

1.pop (KE) #有返回值

2.del Dic[key]

3.popitem () #随机删除

4.clear () #清空字典

Summary of Python string deletions, list deletions, and dictionary deletions

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.