Python 入门demo第一篇
1 #-*- coding: UTF-8 -*- 2.7版本对中文的要求 2 import uuid 3 import socket 4 5 6 def get_mac_address(): 7 mac=uuid.UUID(int = uuid.getnode()).hex[-12:] 8 return ":".join([mac[e:e+2] for e in range(0,11,2)]) 9 10 print get_mac_address(); 11 12 ##获取本机电脑名 在pycharm上的注释快捷键 Ctrl+/ 13 myname = socket.getfqdn(socket.gethostname( )) 14 #获取本机ip 15 myaddr = socket.gethostbyname(myname) 16 print myname 17 print myaddr
开发环境自行解决,个人开发环境是:windows+python2.7+pycharm