- 用法:- class ipaddress.IPv4Address(address)
- 构造一个 IPv4 地址。如果 - address不是有效的 IPv4 地址,则会引发- AddressValueError。- 以下构成有效的 IPv4 地址: - decimal-dot 表示法的字符串,由 0-255 范围内的四个十进制整数组成,用点分隔(例如 - 192.168.0.1)。每个整数代表地址中的一个八位字节(字节)。不允许使用前导零,以防止与八进制表示法混淆。
- 适合 32 位的整数。 
- 打包到长度为 4 的 - bytes对象中的整数(最高有效八位字节在前)。
 - >>> ipaddress.IPv4Address('192.168.0.1') IPv4Address('192.168.0.1') >>> ipaddress.IPv4Address(3232235521) IPv4Address('192.168.0.1') >>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01') IPv4Address('192.168.0.1')- 在 3.8 版中更改:允许使用前导零,即使在看起来像八进制表示法的模棱两可的情况下也是如此。 - 在 3.10 版中更改:前导零不再被容忍,并被视为错误。 IPv4 地址字符串现在被解析为与 glibc 一样严格 - inet_pton().- 在 3.9.5 版中更改:从版本 3.9.5 开始,上述更改也包含在 Python 3.9 中。 - 在 3.8.12 版中更改:从版本 3.8.12 开始,上述更改也包含在 Python 3.8 中。 
相关用法
- Python ipaddress.IPv4Address.reverse_pointer用法及代码示例
- Python ipaddress.IPv4Address.__format__用法及代码示例
- Python ipaddress.IPv4Network.supernet用法及代码示例
- Python ipaddress.IPv4Network.supernet_of用法及代码示例
- Python ipaddress.IPv4Network.address_exclude用法及代码示例
- Python ipaddress.IPv4Interface.ip用法及代码示例
- Python ipaddress.IPv4Network.subnets用法及代码示例
- Python ipaddress.IPv4Interface.with_prefixlen用法及代码示例
- Python ipaddress.IPv4Interface.with_netmask用法及代码示例
- Python ipaddress.IPv4Interface.with_hostmask用法及代码示例
- Python ipaddress.IPv4Network.subnet_of用法及代码示例
- Python ipaddress.IPv4Network.compare_networks用法及代码示例
- Python ipaddress.IPv4Network.hosts用法及代码示例
- Python ipaddress.IPv4Interface.network用法及代码示例
- Python ipaddress.IPv6Address用法及代码示例
- Python ipaddress.collapse_addresses用法及代码示例
- Python ipaddress.summarize_address_range用法及代码示例
- Python ipaddress.v4_int_to_packed用法及代码示例
- Python ipaddress.ip_address用法及代码示例
- Python numpy ipmt用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 ipaddress.IPv4Address。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
