0 python-8.1 List of basic studies

Source: Internet
Author: User

List is the most flexible set of ordered collection object types in Python

It can contain objects of any other type: numbers, strings, even lists

Features: Variable objects, can be modified in situ, can be offset values, shards, method calls

Characteristics:

1. An ordered set of arbitrary objects

2. Read by offset

3. Variable-length, heterogeneous, and arbitrary nesting

4. Belong to the variable sequence

5. Object reference array: A list contains references to 0 or more objects


Operation Explain
L=[] An empty list
l=[0,1,2,3] Four items: index from 0 to 3
l=[' abc ', [' 123 ', ' ABC '] Nested from List
L=list (' abc ') List of items that can be iterated
L=list (range (0,4)) List of items that can be iterated
L[i] Index
L[I][J] Index of Index
L[I:J] Sharding
Len (L) Request length
L1+l2 Add
L*3 Repeat
For x in L:print (x) Iteration
3 in L Member relationships
L.append (1) Growth
L.extend ([1,2,2]) Growth
L.insert (i,x) Insert
L.index (1) Search
L.count (X) Total
L.sort () Sort
L.reverse () Reverse
Del L[k] Delete Element
Del L[i:j] Delete scope
L.pop () Pop
L.remove (2) Remove
L[i:j]=[] Empty
L[i]=1 Index Assignment
l[i:j]=[1,2,3] Shard Assignment
L=[x**2 for x in range (1,4)] List parsing

Right here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 python-8.1 List of basic studies

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.