Basic data type (2), data type (2)

Source: Internet
Author: User

Basic data type (2), data type (2)
I. List

# Create a list # Method 1: name_list = [1, 2, 3, "reese", "neo"] print (name_list) # Method 2: v = list ([1, 2, 3, "reese", "neo"]) print (v)

Supported basic operations:

  • Index
  • Slice
  • Modify
  • Delete
  • Loop
  • Include

 

1. append

 

 

2. clear

 

 

3. copy

 

4. count

 

 

 

5. extend

 

 

6. index

 

7. insert

 

8. pop

 

 

9. remove

 

10. reverse

 

 

11. sort

 

 

Ii. yuanzu
# Create a ancestor #1: v = (1, 2, 3, 4) #2: v = tuple (1, 2, 4 ))

Basic operations:

  • Index
  • Slice
  • Loop, iteratable object
  • Conversion
  • Primary elements of tuples cannot be deleted or modified.

 

 

3. Dictionary

Create a dictionary:

#1:v = {"name": "reese", "age": "18"}#2:v = dict({"name": "reese", "age": "18"})

Common Operations:

  • Key-value pairs. The value in the dictionary can be any value.
  • Boolean values, lists, and dictionaries cannot be keys of dictionaries.
  • Dictionary disorder
  • You can find the specified element by indexing.
  • The dictionary supports del deletion.
  • For Loop

1. fromkeys

 

 

2. get

 

 

3. setdefault

 

 

4. update

 

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.