array
— 高效数值数组
¶
This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by using a type code , which is a single character. The following type codes are defined:
|
类型代码 |
C 类型 |
Python 类型 |
Minimum size in bytes |
注意事项 |
|---|---|---|---|---|
|
|
signed char |
int |
1 |
|
|
|
unsigned char |
int |
1 |
|
|
|
wchar_t |
Unicode 字符 |
2 |
(1) |
|
|
Py_UCS4 |
Unicode 字符 |
4 |
|
|
|
signed short |
int |
2 |
|
|
|
unsigned short |
int |
2 |
|
|
|
signed int |
int |
2 |
|
|
|
无符号 int |
int |
2 |
|
|
|
signed long |
int |
4 |
|
|
|
unsigned long |
int |
4 |
|
|
|
signed long long |
int |
8 |
|
|
|
unsigned long long |
int |
8 |
|
|
|
float |
float |
4 |
|
|
|
double |
float |
8 |
注意事项:
-
它可以是 16 位 (或 32 位) 从属平台。
3.9 版改变:
array('u')现在使用wchar_tas C type instead of deprecatedPy_UNICODE. This change doesn’t affect its behavior becausePy_UNICODEis alias ofwchar_tsince Python 3.3.Deprecated since version 3.3, will be removed in version 3.16: Please migrate to
'w'typecode.