8.7. array
() (array) (sequence) :
| C | Python | () | ||
|---|---|---|---|---|
'b' |
signed char | int | 1 | |
'B' |
unsigned char | int | 1 | |
'u' |
Py_UNICODE | Unicode(unicode) | 2 | (1) |
'h' |
signed short | int | 2 | |
'H' |
unsigned short | int | 2 | |
'i' |
signed int | int | 2 | |
'I' |
unsigned int | int | 2 | |
'l' |
signed long | int | 4 | |
'L' |
unsigned long | int | 4 | |
'q' |
signed long long | int | 8 | (2) |
'Q' |
unsigned long long | int | 8 | (2) |
'f' |
4 | |||
'd' |
double | 8 |
:
'u'Python Unicode (Py_UNICODEwchar_t) 16bit 32bit'u'Py_UNICODEAPI3.3 4.0 .
'q''Q'Python C Clong longWindows__int643.3 .
(C) itemsize
:
-
class
array.array(typecode[, initializer]) typecode initializer bytes-like object
initializer
fromlist()frombytes()fromunicode()() initializerextend()
:
-
array.buffer_info() (address, length)array.buffer_info()[1] * array.itemsizeioctl()() I/OC C++ (
buffer_info()) (buffer Protocol)
-
array.byteswap() () 124 8
RuntimeError
-
array.extend(iterable) iterable iterable
TypeErroriterable
-
array.frombytes(s) (
fromfile())3.2 :
fromstring()frombytes()
-
array.fromfile(f, n) f () n n
EOFErrorfread()
-
array.fromunicode(s) Unicode
'u'ValueErrorUnicodearray.frombytes(unicodestring.encode(enc))
-
array.tobytes() array array bytes (
tofile())3.2 :
tostring()tobytes()
-
array.tofile(f) () file object f
-
array.tounicode() Unicode
'u'ValueErrorUnicodearray.tobytes().decode(enc)
array(typecode, initializer)
initializer
typecode 'u'
array from array import array eval() :
array('l')
array('u', 'hello \u2641')
array('l', [1, 2, 3, 4, 5])
array('d', [1.0, 2.0, 3.14])
structxdrlib- (External Data Representation, XDR)
- Numerical Python
- Numeric Python (NumPy) Numerical Python http://www.numpy.org/