PythonQ 240-8XX Instrukcja Użytkownika Strona 19

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 37
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 18
c
! www.simula.no/˜hpl
Loops over arrays (2)
View array as one-dimensional and iterate over all elements:
for e in a.ravel():
print e
Use ravel() only when reading elements, for assigning it is better
to use shape or reshape first!
For loop over all index tuples and values:
>>> for index, value in ndenumerate(a):
... print index, value
...
(0, 0) 2.0
(0, 1) 6.0
(0, 2) 12.0
(1, 0) 4.0
(1, 1) 12.0
(1, 2) 24.0
Numerical Python – p. 253/728
Przeglądanie stron 18
1 2 ... 14 15 16 17 18 19 20 21 22 23 24 ... 36 37

Komentarze do niniejszej Instrukcji

Brak uwag