Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!newsgate.cuhk.edu.hk!news.netfront.net!not-for-mail From: Nando Newsgroups: it.comp.lang.python Subject: Re: Range ciclo for Date: Wed, 9 Mar 2016 20:46:25 +0100 Organization: Netfront http://www.netfront.net/ Lines: 21 Message-ID: References: NNTP-Posting-Host: 95.236.100.164 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: adenine.netfront.net 1457552787 21419 95.236.100.164 (9 Mar 2016 19:46:27 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Wed, 9 Mar 2016 19:46:27 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Xref: csiph.com it.comp.lang.python:7616 Il 08/03/2016 23:20, Max_Adamo ha scritto: > Il Mon, 29 Feb 2016 15:11:45 +0100, Smith ha scritto: > >> Ciao a tutti, >> vorrei numerare il numero di file all'interno di una directory con >> python: >> > > è sempre bello avere più soluzioni: > > for i in enumerate(os.listdir("/home"), 1): > print "{0} {1}".format(i[0], i[1]) > > non devi fare nemmeno l'import. > Ho provato la tua soluzione, ma non funziona se non importo os o listdir da os. Stranamente, l'help trova os.listdir anche se non importata ma poi python non me la lascia usare. --- news://freenews.netfront.net/ - complaints: news@netfront.net ---