Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3030
| From | marc.marc@marc.org |
|---|---|
| Newsgroups | fr.comp.lang.python |
| Subject | Re: remplir un tableau |
| Date | 2018-01-31 09:25 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <p4ruid$1jsu$1@gioia.aioe.org> (permalink) |
| References | <5a6fa2b6$0$7180$426a74cc@news.free.fr> |
Bonjour, je ne réponds pas à la question, mais pour ce genre d'opération il vaut bien mieux à mon avis utiliser les tableaux (arrays) numpy, sur lesquels on peut de plus faire toutes sortes de calculs, que les listes: import numpy as np import pylab as pl image = np.random.randint(low=0,high=10,size=(50,50)) pl.imshow(image,cmap="gray") pl.show() Amicalement. Marc Le 29/01/2018 à 23:39, Fabrice a écrit : > Bonjour, > > je voulais remplir un tableau avec des nombres aléatoires mais j'ai 50 > fois la même ligne ! > > j'ai fait : > > import matplotlib.pyplot as plt > import random > > image = [[0]*50]*50 > > for ligne in range(50): > for pixel in range(50): > image[ligne][pixel] = random.randint(0, 10) > > plt.imshow(image,cmap='gray') > plt.show() > > Pourquoi ? > > Merci, > Fabrice. > > --- > L'absence de virus dans ce courrier électronique a été vérifiée par le > logiciel antivirus Avast. > https://www.avast.com/antivirus >
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
remplir un tableau Fabrice <professeur.leclercq@gmail.com> - 2018-01-29 23:39 +0100
Re: remplir un tableau Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2018-01-30 07:19 +0100
Re: remplir un tableau Fabrice <professeur.leclercq@gmail.com> - 2018-01-31 16:15 +0100
Re: remplir un tableau Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2018-01-31 18:50 +0100
Re: remplir un tableau Nicolas <nicolasp@aaton.com> - 2018-01-30 09:53 +0100
Re: remplir un tableau Fabrice <professeur.leclercq@gmail.com> - 2018-01-31 16:17 +0100
Re: remplir un tableau marc.marc@marc.org - 2018-01-31 09:25 +0100
Re: remplir un tableau Fabrice <professeur.leclercq@gmail.com> - 2018-01-31 16:23 +0100
csiph-web