Python Forum
How to generate a log in a list style?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to generate a log in a list style?
#1
Hello Guys, I have a code for bkp my network devices, I have placed some improvement to generate a log for document the failed devices, so I can check it manually.
My code is generating the output I want in a text, however I'd like to improve the formatting...

The code generates the log file in one single line and my goal is to generate a list instead.

my code is:
except Exception as ex:
           
            print('An exception occurred.  Details', ex)
            output2 = ip + ','
            print output2
            filename2 = "%s_%.2i-%.2i-%i_%.2i-%.2i-%.2i" % (filename_prefix2,now.day,now.month,now.year,now.hour,now.minute,now.second)
            ff = open(filename2, 'a')
            ff.write(output2)
            ff.close()
            f.close() 
and I got the text file like this:
[inline]
192.168.60.3,10.185.88.1,10.147.63.253,10.0.15.253,172.30.4.4,172.30.7.3,172.30.7.4,10.177.105.2,10.156.63.253,192.168.224.241,
[/inline]

Id like to getsomething like that:

[inline]
192.168.60.3,
10.185.88.1,
10.147.63.253,
10.0.15.253,
172.30.4.4,
172.30.7.3,
172.30.7.4,
10.177.105.2,
10.156.63.253,
192.168.224.241,
[/inline]
Reply


Messages In This Thread
How to generate a log in a list style? - by wagnergt12 - Apr-21-2020, 08:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Generate a list sasitha96 5 2,375 Sep-20-2021, 07:03 PM
Last Post: sasitha96
  extract first and last 5 elements from given list and generate a new list. Raj_Kumar 1 2,382 Dec-07-2019, 05:03 PM
Last Post: ichabod801
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 2,320 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu
  Generate list in class P13N 7 4,376 Dec-28-2018, 10:08 PM
Last Post: P13N
  Generate a list of numbers within a list of arbitrary numbers Takeshio 4 3,503 Nov-08-2018, 12:29 AM
Last Post: Takeshio
  How to generate the list I want? Krookroo 6 4,125 Sep-07-2017, 02:06 PM
Last Post: Krookroo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020