lnote
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import string
import random
num=int(sys.argv[1])

#随机生成一个MAC地址
def creat_mac():
    MAC=\'41-AF\'
    hex_num=string.hexdigits
    for i in range(4):
        n=random.sample(hex_num,2)
        sn=\'-\'+\'\'.join(n).upper()
        MAC+=sn
    return MAC

#随机生成n个
def creat_mac1():
    with open(\'mac.txt\',\'w\')as f:
        for i in range(num):
            mac=creat_mac()
            print(mac)
            f.write(mac+\'\n\')
creat_mac1()

 

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-19
  • 2021-07-03
  • 2022-01-16
  • 2022-12-23
  • 2021-09-18
  • 2021-08-25
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-11-28
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2022-01-17
  • 2022-02-07
相关资源
相似解决方案