PythonQ 240-8XX Manual do Utilizador Página 11

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 37
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 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 página 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 ... 36 37

Comentários a estes Manuais

Sem comentários