我使用的是通过数据库导入常见的MAC段,各位使用的时候自定义下 macs 记得直接十六进制的自定义就可以,在上文中我分享过常见的MAC地址段,可以参考下。

import random
def randomMAC():
    macs = mysql.getMac()
    mac_1 = macs[1]
    mac_2 = macs[2]
    mac_3 = macs[3]
    mac = [
        random.randint(0x00, 0x7f),
        random.randint(0x00, 0xff),
        random.randint(0x00, 0xff) ]
    mac = ':'.join(map(lambda x: "%02x" % x, mac))
    mac = mac_1+':'+mac_2+':'+mac_3+':'+mac
    return mac

最后修改:2020 年 04 月 25 日
如果觉得我的文章对你有用,请随意赞赏