mac:mac地址生成器

madmac的Python项目详细描述


马德马克Build Status

测试人员的mac地址生成器库。

内容

安装

使用pip

pip install madmac

使用源:

$ git clone https://github.com/laminko/madmac.git
$ cd madmac
$ python setup.py install

使用量

作为命令

可以使用madmac作为命令。下面将生成随机的mac地址。

madmac

要查看帮助,请输入madmac --help

madmac --help
usage: madmac [-h][-o OUI][-r START][-s STOP][-t TOTAL][-d DELIMITER][-c CASE]

MAC address generator library for testers.

optional arguments:
  -h, --help            show this help message and exit
  -o OUI, --oui OUI     6-digit organizationally unique identifier
  -r START, --start START
                        NIC specific start address
  -s STOP, --stop STOP  NIC specific end address
  -t TOTAL, --total TOTAL
                        Number of MACs to generate
  -d DELIMITER, --delimiter DELIMITER
                        Delimiter for MAC address
  -c CASE, --case CASE  Use lower or upper

NOTE: madmac is not a binary file. You need to install python 3.5 to execute the command.

作为模块

madmac模块导入MacGenerator类。使用MacGenerator创建一个对象并调用其成员generate()函数。generate()函数将返回python生成器对象。

下面的代码将使用默认值生成单个mac地址。

frommadmacimportMacGeneratormacg=MacGenerator()macs=macg.generate()# generator object which contains one itemfrompprintimportpprintpprint(list(macs))

默认值如下:

# 'oui':  None,# 'start': None,# 'stop': None,# 'total': 1,# 'delimiter': ':',# 'case': 'lower'

我们可以提供oui

frommadmacimportMacGeneratormacg=MacGenerator(oui='F0-9F-C2')list(macg.generate())

如果已知,还指定start地址和end地址:

frommadmacimportMacGeneratorstart='00-B0-A0'stop='00-B0-DF'macg=MacGenerator(start=start,stop=stop)

NOTE: Above snippet describes to use random oui, but to use certain range from start and stop values. It will ignore total parameter. Delimiter and Case will be default values.

有时,我们可能需要生成一定数量的mac地址:

frommadmacimportMacGeneratormacg=MacGenerator(total=100)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何显示因用户而异的SQLite存储数据?   转换java。sql。将映射传递给Jackon的valueToTree方法时StringNode的时间戳   从java中的列表json获取值   unicode Java字符存储在什么编码中?   java如何让Spring数据存储库中的默认方法命中缓存?   java使用readClassDescriptor()和resolveClass()来允许序列化版本控制   数组通过另一个矩阵的一部分填充矩阵   如果包含使用正则表达式的字符串,则替换父XML标记的java   java清除SharedReference中的单个变量   java将变量值从一个jsp页面传输到另一个jsp页面   java JDBC+SQLite:DriveManager不加载所需的驱动程序   相同源代码的java Kotlin构建生成不同的二进制文件   Java中的元组枚举