"Python" "sequence"

Source: Internet
Author: User

1. Array

1?? and list

First introduce

From array Import array

The list is then passed directly to the array parameter into the constructor. (I don't know if it's called a constructor)

Np.array (' d ', [+])

Turn back then call the ToList function

_.tolist ()

2?? Enumerations & Common Methods

Array Use method:
Type code C type Minimum size in bytes
' C ' character 1
' B ' signed integer 1
' B ' unsigned integer 1
' U ' Unicode character 2
' H ' signed integer 2
' H ' unsigned integer 2
' I ' signed integer 2
' I ' unsigned integer 2
' L ' signed integer 4
' L ' unsigned integer 4
' F ' floating point 4
' d ' floating point 8
From array Import *
Create an array of type Interger
Myarr = Array ("L") <--------Creating arrays
Myarr.append (3) <----------------append elements
Myarr.append (1)
Myarr.append (8)

Delete Last
Myarr.pop ()
Deletes the first specified x
Myarr.remove (x)

Take the value of the array ..... by subscript
NUM1 = Myarr[0] <-----------first value

Specify the location, .... Inserting values

Myarr.insert (6,10) 6 means subscript .... 10 indicates the value to insert


Array reverse order .....
Myarr.reverse ()

"Python" "sequence"

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.