随机生成mac地址

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

随机生成mac地址

import random
def random_MAC():
	random_mac=[11,22,33,random.randint(0x00,0xff),random.randint(0x00,0xff),random.randint(0x00,0xff)]
	temp=':'.join(map(lambda x: "%02x" % x,random_mac))
	message_to_write=temp+', '+',dctest'+'\n'
	return message_to_write
	
def main():
	fileobj=open('mac_test.csv','w')
	for i in range(100):
		fileobj.write(random_MAC())

	fileobj.close()

main()

转载于:https://my.oschina.net/donngchao/blog/2999623

你可能感兴趣的:(随机生成mac地址)