tech:python
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Python
Windows statt <Strg> D: <Strg> Z & <Enter>
Weblinks
Tipps und Tricks
Ein Matrix transponieren (Zeilen und Spalten vertauschen):
from pprint import pprint as pp
T1 = [[11, 12, 13, 14, 15, 16, 17, 18],[21, 22 ,23, 24, 25,26, 27, 28],[31, 32 ,33, 34, 35, 36, 37, 38]]
pp(T1)
# [[11, 12, 13, 14, 15, 16, 17, 18],
# [21, 22, 23, 24, 25, 26, 27, 28],
# [31, 32, 33, 34, 35, 36, 37, 38]]
T2 = list(zip(*T1))
pp(T2)
# [(11, 21, 31),
# (12, 22, 32),
# (13, 23, 33),
# (14, 24, 34),
# (15, 25, 35),
# (16, 26, 36),
# (17, 27, 37),
# (18, 28, 38)]
tech/python.1701268721.txt.gz · Zuletzt geändert: von lutz