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"
相关推荐
LczPtr 2020-05-09
chuckchen 2020-10-31
Will0 2020-10-12
Dreamhome 2020-10-09
xirongxudlut 2020-09-28
星辰大海的路上 2020-09-13
chaochao 2020-08-31
猪猪侠喜欢躲猫猫 2020-08-17
快递小可 2020-08-16
shengge0 2020-07-26
巩庆奎 2020-07-21
张文倩数据库学生 2020-07-19
xirongxudlut 2020-07-18
Ericbig 2020-07-18
kyelu 2020-07-09
liangzhouqu 2020-07-07
GuoSir 2020-06-28