如何访问特定号码的ipv4地址?

How to access specific numbers of a ipv4 address?

我有很多 ipv4 地址,第四个八位字节用 3 个字符串混淆,例如 (###.###.###.xxx),我需要定义点之间的每个数字。
例如 22.123.567.cjjw=22x=123y=567.
有时第一个八位字节有 3 个数字或(你怎么看)2,有时只有 1。

谁能帮帮我?

您可以使用str.split()

>>> ip = '22.123.567.cjj'
>>> w, x, y, z = ip.split('.')
>>> print(w, x, y, z)
22 123 567 cjj

您可以使用 split() 函数。

>>> address = "127.0.10.15"
>>> print(address.split('.'))
['127', '0', '10', '15']