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


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

Re: Python + Ping + File csv

From Max_Adamo <maxadamo@usenet.cnntp.org>
Newsgroups it.comp.lang.python
Subject Re: Python + Ping + File csv
Date 2016-04-08 19:11 +0000
Organization A noiseless patient Spider
Message-ID <ne8voi$aqn$3@dont-email.me> (permalink)
References <blsNy.43681$pt.43370@tornado.fastwebnet.it>

Show all headers | 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