Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.python > #7637

Re: Python + Ping + File csv

Path csiph.com!news.fcku.it!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Max_Adamo <maxadamo@usenet.cnntp.org>
Newsgroups it.comp.lang.python
Subject Re: Python + Ping + File csv
Date Fri, 8 Apr 2016 19:11:14 -0000 (UTC)
Organization A noiseless patient Spider
Lines 25
Message-ID <ne8voi$aqn$3@dont-email.me> (permalink)
References <blsNy.43681$pt.43370@tornado.fastwebnet.it>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Fri, 8 Apr 2016 19:11:14 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="def1a60fa1fd3e6d9dd9b3c31de5190b"; logging-data="11095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LGSjgsowRh7A7FGZNnlMpg7XqFViG25Y="
User-Agent Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)
X-Face /home/maxadamo/.signature/X-Face
Cancel-Lock sha1:N739eGllt7KUo6268eRUW8rLZEE=
Xref csiph.com it.comp.lang.python:7637

Show key headers only | View raw


Il Thu, 07 Apr 2016 14:25:43 +0200, Smith ha scritto:

> Ciao a tutti,
> ho questo piccolo script che ping determinati indirizzi ip. Considerando
> che sono un neofita del linguaggio di programmazione Python, mi potete
> aiutare a modificare queste righe al fine di mettere l'output in un file
> csv ?
> Grazie in anticipo

questa è roba che trovi un po' ovunque su google... comunque, devi aprire 
un file in append e scrivere con write. Ci sono due tecniche, in questo 
caso è più semplice così: 

f = open('/my/file.txt')

qui al posto di print (o oltre a print) inserisci il ciclo for che avrà:
f.write("ping to {0} OK\n".format(address)
# le virgole del cvs le metto come vuoi

e alla fine:

f.close()

-- 
Massimiliano Adamo

Back to it.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Python + Ping + File csv Smith <smith@a-team.it> - 2016-04-07 14:25 +0200
  Re: Python + Ping + File csv Max_Adamo <maxadamo@usenet.cnntp.org> - 2016-04-08 19:11 +0000
    Re: Python + Ping + File csv Max_Adamo <maxadamo@usenet.cnntp.org> - 2016-04-09 14:19 +0000

csiph-web