Array in Python
Arrays
can only contain values corresponding to same data opposed to lists which
contains value corresponding to different data types.
Syntax
arrayName
= array(typecode, [Initializers]>
Code
Snippet
arraydata=array('c',
'hello world')
for
letter in arraydata:
print letter
Typecodes
‘b’
-> signed integer of size 1 byte
‘B’
-> unsigned integer of size 1 byte
‘c’
-> character of size 1 byte
‘u’
-> unicode character of size 2 bytes
‘h’
-> signed integer of size 2 bytes
‘H’
-> unsigned integer of size 2 bytes
‘i’
-> signed integer of size 2 bytes
‘I’
-> unsigned integer of size 2 bytes
‘w’
-> unicode character of size 4 bytes
‘l’
-> signed integer of size 4 bytes
‘L’
-> unsigned integer of size 4 bytes
‘f’
-> floating point of size 4 bytes
‘d’
-> floating point of size 8 bytes
Array in Python
Reviewed by Rupesh
on
08:50
Rating:
No comments: