python - 生成从 1.1.1.1 到 255.255.255.255 的所有数字
问题描述
所以我想用 Python 编写一个脚本,生成从 1.1.1.1 到 255.255.255.255 的所有数字(例如,1.1.1.1、1.1.1.2、1.1.1.3、...)我怎么能这样做呢?谢谢。
解决方案
Python 3 具有以下ipaddress
模块:
import ipaddress
for address in range(0x01010101, 0xffffffff):
print(ipaddress.IPv4Address(address))
推荐阅读
- mysql - 如何加入两个表并动态进行 Pivot
- django - 传递正确的 urls.py 模式
- python - 翻转numpy数组中的行
- java - java.net.URLEncoder 用 '+' 字符替换空格
- perl - 不能在没有包或对象引用的情况下调用方法“文件名”
- git - 用于从其他程序(例如 Git、PowerShell 或命令行)打开文件列表的单行命令
- asp.net-core - ASP.NET CORE RAZOR PAGES - 重载方法
- excel - EXCEL:对多行求和
- c++ - C++ 中的函子和 lambda
- omnet++ - Omnet++ 问题:对抽象 L3Address SlectedNodes[] 的字段使用标准容器类;// 将使用 std::vector?