python获取mac地址和ip地址
#!/usr/bin/python# get ipimport subprocessdef get_ip():args='''ifconfig|grep 'inet addr:'|awk '{print $2}'|awk -F':' '{print $2}'|grep -v "127.0.0.1"'''t=subprocess.Popen(args,shell=True...
·
#!/usr/bin/python
# get ip
import subprocess
def get_ip():
args='''ifconfig|grep 'inet addr:'|awk '{print $2}'|awk -F':' '{print $2}'|grep -v "127.0.0.1"'''
t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]
print(t, type(t))
t = str(t)
return t.split('\n')[0]
print(get_ip())
# 获取mac唯一地址
def get_max_address():
import uuid
node=uuid.getnode()
print('node:', node)
mac=uuid.UUID(int=node).hex[-12:]
return mac
print(get_max_address())
更多推荐
已为社区贡献3条内容
所有评论(0)