用法:
hosts()
返回網絡中可用主機的迭代器。可用的主機是屬於網絡的所有IP地址,除了網絡地址本身和網絡廣播地址。對於掩碼長度為 31 的網絡,網絡地址和網絡廣播地址也包含在結果中。掩碼為 32 的網絡將返回一個包含單個主機地址的列表。
>>> list(ip_network('192.0.2.0/29').hosts()) [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'), IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'), IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')] >>> list(ip_network('192.0.2.0/31').hosts()) [IPv4Address('192.0.2.0'), IPv4Address('192.0.2.1')] >>> list(ip_network('192.0.2.1/32').hosts()) [IPv4Address('192.0.2.1')]
相關用法
- Python ipaddress.IPv4Network.supernet用法及代碼示例
- Python ipaddress.IPv4Network.supernet_of用法及代碼示例
- Python ipaddress.IPv4Network.address_exclude用法及代碼示例
- Python ipaddress.IPv4Network.subnets用法及代碼示例
- Python ipaddress.IPv4Network.subnet_of用法及代碼示例
- Python ipaddress.IPv4Network.compare_networks用法及代碼示例
- Python ipaddress.IPv4Address.reverse_pointer用法及代碼示例
- Python ipaddress.IPv4Address.__format__用法及代碼示例
- Python ipaddress.IPv4Interface.ip用法及代碼示例
- Python ipaddress.IPv4Interface.with_prefixlen用法及代碼示例
- Python ipaddress.IPv4Interface.with_netmask用法及代碼示例
- Python ipaddress.IPv4Interface.with_hostmask用法及代碼示例
- Python ipaddress.IPv4Address用法及代碼示例
- 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.IPv4Network.hosts。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。