About array:
Python does not have an array of this argument, some that list and tuple, list properties will have an array of other languages.
As for the difference between the list and tuple, that list can modify the contents and size of the runtime, after the first tuple creation and assignment, can not modify the contents inside again
However, there is a python module array, for providing basic numeric, character type array. For receiving basic types of symbol character, integer, floating point and so on.
This module is mainly used for operations on binary buffer, flow
For example, modify the MP3 ID3V1 tags, you can use the array
The following is the type of initialization array support
Type code | C Type | Python Type | Minimum size in bytes |
---|---|---|---|
'c' | char | character | 1 |
'b' | signed char | int | 1 |
'B' | unsigned char | int | 1 |
'In' | Py_UNICODE | Unicode character | 2 (see note) |
'h' | signed short | int | 2 |
'H' | unsigned short | int | 2 |
'i' | signed int | int | 2 |
'I' | unsigned int | long | 2 |
'l' | signed long | int | 4 |
'L' | unsigned long | long | 4 |
'f' | float | float | 4 |
'd' | double | float | 8 |
Use demo:
Create an array of type interger
myarr = array ( "l") <--- create an array
myarr.append (3) <--- additional element
myarr.append(1)
myarr.append(8)
Delete the last
myarr.pop()
Delete the first designated X
myarr.remove(x)
An array of values taken by the subscript
num1 = myarr [0] <---- a first value
Specified position, interpolated values
myarr.insert(6,10)
6 represents a subscript, represents the value 10 to be inserted
Array reverse order
myarr.reverse()
About array:
Python does not have an array of this argument, some that list and tuple, list properties will have an array of other languages.
As for the difference between the list and tuple, that list can modify the contents and size of the runtime, after the first tuple creation and assignment, can not modify the contents inside again
However, there is a python module array, for providing basic numeric, character type array. For receiving basic types of symbol character, integer, floating point and so on.
This module is mainly used for operations on binary buffer, flow
For example, modify the MP3 ID3V1 tags, you can use the array
The following is the type of initialization array support
Type code | C Type | Python Type | Minimum size in bytes |
---|---|---|---|
'c' | char | character | 1 |
'b' | signed char | int | 1 |
'B' | unsigned char | int | 1 |
'In' | Py_UNICODE | Unicode character | 2 (see note) |
'h' | signed short | int | 2 |
'H' | unsigned short | int | 2 |
'i' | signed int | int | 2 |
'I' | unsigned int | long | 2 |
'l' | signed long | int | 4 |
'L' | unsigned long | long | 4 |
'f' | float | float | 4 |
'd' | double | float | 8 |
Use demo:
Create an array of type interger
myarr = array ( "l") <--- create an array
myarr.append (3) <--- additional element
myarr.append(1)
myarr.append(8)
Delete the last
myarr.pop()
Delete the first designated X
myarr.remove(x)
An array of values taken by the subscript
num1 = myarr [0] <---- a first value
Specified position, interpolated values
myarr.insert(6,10)
6 represents a subscript, represents the value 10 to be inserted
Array reverse order
myarr.reverse()