python 打印本机IP MAC地址

# -*- coding: utf-8 -*-
import socket
#获取本机电脑名
myname = socket.getfqdn(socket.gethostname(  ))
#获取本机ip
myaddr = socket.gethostbyname(myname)
print(myname)
print(myaddr)

python 打印本机IP MAC地址_第1张图片

import socket
#获取本机电脑名
myname = socket.getfqdn(socket.gethostname())
#获取本机ip
myaddr = socket.gethostbyname(myname)
print(myname)
print(myaddr)

IPAddress="http:\\\\"+str(myaddr)

f = open('FileName20.txt','r',encoding='utf8')
w = open('HTTPFileName192.txt','w',encoding='utf8')
for lines in f.readlines():
    print(lines[2:])
    w.write(IPAddress+lines[2:]);     
    #print(lines,end='')
f.close()
w.close()

你可能感兴趣的:(代码,python,python)