I currently have a text file in JSON format of ip addresses with their ports, example:
[
{
"ip": "192.0.3.202",
"port": [
22,
53,
80,
443]
},
{
"ip": "192.0.3.253",
"port": [
179]
}
]
I want to print out only the ip and on another line with ports. Expected output:
IP: 192.0.3.202
Port: 22,53,80,443
IP: 192.0.3.253
Port: 179
I have tried doing this:
i=0
while True:
ip_test = open('test.txt', 'r')
ip_line=ip_test.readlines()
a=ip_line[i].strip("{\"ip\": ")
print(a)
However my output is only stripping out the first few characters