标签:open imp none mac join 一个 with open splay mac地址
#!/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()
标签:open imp none mac join 一个 with open splay mac地址
原文地址:https://www.cnblogs.com/lnote/p/14402818.html