I have an IP address that I need to split in order to know the location of the device.
s = "11.19.27.55"
ip = [item[::-1] for item in s[::-1].split('.', 1)][::-1]
print(ip)
Result:
['11.19.27', '55']
How can I now compare to certain parts of this result? The first part I need for location second part for knowing which device it is.
I found the solution myself:
print(ip[0]) for the first part
print(ip[1]) for the second part
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.