一个用于生成大量mac地址的python脚本

 

import random


def generate_mac_address():
    mac = [random.choice('0123456789ABCDEF') for _ in range(12)]
    p = 2
    for i in range(5):
        mac.insert(p, '-')
        p += 3
    return ''.join(mac)


num_addresses = 310000

mac_addresses = set()

while len(mac_addresses) < num_addresses:
    mac = generate_mac_address()
    mac_addresses.add(mac)

with open('mac_addresses.csv', 'w') as file:
    for mac in mac_addresses:
        file.write(mac + '\n')

 

posted @ 2024-05-16 23:58  Jackie_JK  阅读(43)  评论(0编辑  收藏  举报