Python3 code to display hostname and IP address
Posted python-abc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python3 code to display hostname and IP address相关的知识,希望对你有一定的参考价值。
OS: Windows 7
#!/usr/bin/env python3 # Python3 code to display hostname and # IP address # Importing socket library import socket # Function to display hostname and # IP address def get_Host_name_IP(): try: host_name = socket.gethostname() host_ip = socket.gethostbyname(host_name) print("Hostname : ",host_name) print("IP : ",host_ip) except: print("Unable to get Hostname and IP") # Driver code get_Host_name_IP() #Function call #This code is conributed by "Sharad_Bhardwaj"
以上是关于Python3 code to display hostname and IP address的主要内容,如果未能解决你的问题,请参考以下文章
山科 STUST OJ Problem B: 编写函数:String to Double (II) (Append Code)
python3 split( ) not enough values to unpack(expceted 2, got 1)
npm ERR! code ECONNRESET npm ERR! errno ECONNRESET npm ERR! network request to http://registry.npm.t