Files can only be installed once

Source: Internet
Author: User
Tags for in range

1 def  2     mac=uuid. UUID (int = Uuid.getnode ()). hex[-123     return":"   for in range (0,11,2)])

Get Computer name

1 Import Socket 2 socket.gethostname ()

Get host extranet IP under Linux

1 ImportSocket2 ImportFcntl3 Importstruct4 defget_ip_address (ifname):5s =Socket.socket (socket.af_inet, socket. SOCK_DGRAM)6     returnSocket.inet_ntoa (Fcntl.ioctl (7 S.fileno (),80x8915,#siocgifaddr9Struct.pack ('256s', ifname[:15])Ten) [20:24]) One PrintGet_ip_address ('Lo') A PrintGet_ip_address ('eth0')

Win Linux compatibility mode

1 ImportRe,urllib22 classGetmyip:3     defGetIP (self):4         Try:5Myip = Self.visit ("http://www.ip138.com/ip2city.asp")6         except:7             Try:8Myip = Self.visit ("http://www.bliao.com/ip.phtml")9             except:Ten                 Try: OneMyip = Self.visit ("http://www.whereismyip.com/") A                 except: -Myip ="So sorry!!!" -         returnMyip the     defVisit (self,url): -Opener =urllib2.urlopen (URL) -         ifURL = =Opener.geturl (): -str =Opener.read () +         returnRe.search ('\d+\.\d+\.\d+\.\d+', str). Group (0) -Getmyip =Getmyip () +Localip =Getmyip.getip () A PrintLocalip

Get System Information

There's a platform module in Python that can get information about the operating system.
Import Platform
Platform.machine () # Returns the machine type, e.g. ' i386 '

Platform.node () # Returns the computer ' s network name

Platform.platform (Aliased=0, terse=0) # Returns A single string identifying the underlying platform

Platform.processor () # Returns The (true) processor name

Platform.python_branch () # Returns A string identifying the Python implementation branch.

Platform.python_build () # Returns a tuple (Buildno, builddate) stating the Python build number and date as strings.

Platform.python_compiler () # Returns A string identifying the compiler used for compiling python.

Platform.python_version () # Returns the Python version as String ' Major.minor.patchlevel '

Platform.release () # Returns The system ' s release, e.g. ' 2.2.0 ' or ' NT '

Platform.system () # Returns the System/os name, e.g. ' Linux ', ' Windows ' or ' Java '.

Platform.uname () # Fairly portable Uname interface. Returns a tuple of strings (system,node,release,version,machine,processor) identifying the underlying platform.

Platform.win32_ver (release= ", version=", csd= ", ptype=") # Get additional version information from the Windows Regi Stry and return a tuple (VERSION,CSD,PTYPE) referring to version number, CSD level and OS type (Multi/single processor).

Linux system Python gets memory, CPU, load, network traffic, hard disk and other information

http://blog.csdn.net/huguangshanse00/article/details/17053789

Http://blog.sina.com.cn/s/blog_62dc8af90102wr1j.html

Python gets CPU, hard disk, BIOS, motherboard serial number under Windows

Files can only be installed once

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.