Advertisement
calfred2808

#Python Get IP Address

Jul 19th, 2020
1,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. # importing socket module
  2. import socket
  3.  
  4. # getting machine name
  5. hostname = socket.gethostname()
  6.  
  7. # getting IP Address
  8. IPAddr = socket.gethostbyname(hostname)
  9.  
  10. # printing hostname
  11. print("Your Computer Name is:" + hostname)
  12.  
  13. # printing IP Address
  14. print("Your Computer IP Address is:" + IPAddr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement