PythonQ 240-8XX Manual de usuario Pagina 11

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 37
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 10
c
! www.simula.no/˜hpl
Array construction from a Python list
array(list, [datatype]) generates an array from a list:
>>> pl = [0, 1.2, 4, -9.1, 5, 8]
>>> a = array(pl)
The array elements are of the simplest possible type:
>>> z = array([1, 2, 3])
>>> print z # array of integers
[1 2 3]
>>> z = array([1, 2, 3], float)
>>> print z
[1. 2. 3.]
Atwo-dim.arrayfromtwoone-dim.lists:
>>> x = [0, 0.5, 1]; y = [-6.1, -2, 1.2] # Python lists
>>> a = array([x, y]) # form array with x and y as rows
From array to list: alist = a.tolist()
Numerical Python – p. 245/728
Vista de pagina 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 ... 36 37

Comentarios a estos manuales

Sin comentarios