Learning python with day to day stuff I normally do in other languages. I am parsing a netstat dump file to get a sorted unique list of remote IPs. I get the ip addresses from a text file and read them into an array (line by line).
x.xx.xxx.xxx
yy.yy.yyy.yyy
etc.
I found code that sorts the array:
The sorting is correct but the output is more than just the IP address. How do I get the output array just the IP address without [IPv4Address('') so I can remove duplicates in the next step?
x.xx.xxx.xxx
yy.yy.yyy.yyy
etc.
I found code that sorts the array:
import ipaddress new_list = [] for element in IP_Array: new_list.append(ipaddress.ip_address(element)) new_list.sort()but the output is: [IPv4Address('x.xx.xx.xxx'), ...
The sorting is correct but the output is more than just the IP address. How do I get the output array just the IP address without [IPv4Address('') so I can remove duplicates in the next step?
buran write Nov-10-2020, 08:47 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.