用法:
ipaddress.ip_address(address)
根據作為參數傳遞的 IP 地址返回
IPv4Address
或IPv6Address
對象。可以提供 IPv4 或 IPv6 地址;默認情況下,小於2**32
的整數將被視為 IPv4。如果address
不代表有效的 IPv4 或 IPv6 地址,則會引發ValueError
。>>> ipaddress.ip_address('192.168.0.1') IPv4Address('192.168.0.1') >>> ipaddress.ip_address('2001:db8::') IPv6Address('2001:db8::')
相關用法
- Python ipaddress.collapse_addresses用法及代碼示例
- 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.summarize_address_range用法及代碼示例
- Python ipaddress.v4_int_to_packed用法及代碼示例
- Python ipaddress.IPv4Interface.with_hostmask用法及代碼示例
- Python ipaddress.IPv4Network.subnet_of用法及代碼示例
- Python ipaddress.IPv4Address用法及代碼示例
- Python ipaddress.IPv6Address用法及代碼示例
- Python ipaddress.IPv4Network.compare_networks用法及代碼示例
- Python ipaddress.IPv4Network.hosts用法及代碼示例
- Python ipaddress.IPv4Interface.network用法及代碼示例
- Python numpy ipmt用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 ipaddress.ip_address。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。