Python gets native IP, computer name, MAC address __python

Source: Internet
Author: User
Tags comparable get ip uuid
#_ *_ coding:utf-8 _*_
Import socket
import getpass
import platform
import uuid #通用唯一识别码


myname1=s Ocket.getfqdn (Socket.gethostname ())
#socket. GETFQDN (name) converts an IP address string that is separated by a dot number into a full domain name
#或者这样
myname2= Platform.uname () [1]


myaddr=socket.gethostbyname (myname1)
#socket. gethostbyname (hostname) Resolves the host name to a dot-delimited IP address string


user=getpass.getuser ()
#获得机器名


myarchitecture=platform.architecture ()
#返回系统架构信息, it doesn't seem to be accurate


myplatform=platform.platform ()


mac=uuid. UUID (Int=uuid.getnode ())


mac=mac.hex[-12:]


print myname1
print myname2
print myaddr
Print user
print myarchitecture
print myplatform
print MAC

Output:

>>>
PC201401131620
PC201401131620
169.254.196.106
Administrator
(' 32bit ', ' WindowsPE ')
windows-7-6.1.7601-sp1
0cd2928db52a
Feel that the return schema information is not accurate

My computer is 64-bit.


These feel python powerful, get IP two rows OK, far from c comparable, although there is nothing comparable haha: blame me not deep into C-. -。

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.