Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3385
| Path | csiph.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news.uzoreto.com!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!fdn.fr!news.ortolo.eu!news.izac.org!reader |
|---|---|
| From | Benoit Izac <use.reply.to@INVALID.ADDRESS> |
| Newsgroups | fr.comp.lang.python |
| Subject | Re: Création liste en ligne en .txt |
| Date | Thu, 19 Nov 2020 16:14:33 +0100 |
| Message-ID | <87ft55qsyu.fsf@izac.org> (permalink) |
| References | <kdadnUbx854BgijCnZ2dnUU798zNnZ2d@giganews.com> <87k0uir40q.fsf@izac.org> <W4adnfT3mqd2vivCnZ2dnUU798zNnZ2d@giganews.com> |
| Reply-To | benoit.izac@free.fr |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | keg.izac.org; logging-data="1127"; mail-complaints-to="usenet@izac.org" |
| Xref | csiph.com fr.comp.lang.python:3385 |
Show key headers only | View raw
Bonjour,
Le 19/11/2020 à 08:51, thomasdeshayes a écrit dans le message
<W4adnfT3mqd2vivCnZ2dnUU798zNnZ2d@giganews.com> :
>>> Je souhaite réaliser le jeu du pendu avec une liste que j'ai
>>> crée en
>>> .txt, mais je rencontre un problème avec l'importation de la liste
>>> (les mots sont en lignes et non en colonne), c'est-Í -dire que je
>>> voudrai prendre un mot de la liste mais python me prend toutes la
>>> ligne de la liste.
>>>
>>> PS : les mots sont séparés uniquement par des points-virgules.
>>>
>>> Pouvez-vous m'aider, s'il vous plait
>>>
>>>
>> On devrait pouvoir mais tu as omis de nous montrer ton code.
>
> Oui, excusez moi, je vous envoie le code ci-dessous :
>
> #Permet de choisir un mot dans le dossier
> mot = [ ]
> with open ("mot.txt","r") as doc :
> for l in doc :
> mot.append(l.rstrip("\n"))
Là effectivement tu ajoutes la ligne entière.
mot.extend(l.rstrip("\n").split(";"))
[je n'ai pas regardé la suite]
--
Benoit Izac
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Création liste en ligne en .txt ThomasDeshayes <nospam_t.deshayes2111@laposte.net.invalid> - 2020-11-18 07:20 -0600
Re: Création liste en ligne en .txt Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-11-18 18:03 +0100
Re: Création liste en ligne en .txt thomasdeshayes <nospam_t.deshayes2111@laposte.net.invalid> - 2020-11-19 01:51 -0600
Re: Création liste en ligne en .txt Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-11-19 16:14 +0100
Re: Création liste en ligne en .txt thomasdeshayes <nospam_t.deshayes2111@laposte.net.invalid> - 2020-11-24 08:31 -0600
csiph-web