Skip to content

Instantly share code, notes, and snippets.

@p208p2002
Created March 4, 2019 05:26
Show Gist options
  • Select an option

  • Save p208p2002/a68cba6a55131ceac78cc8c298b894ba to your computer and use it in GitHub Desktop.

Select an option

Save p208p2002/a68cba6a55131ceac78cc8c298b894ba to your computer and use it in GitHub Desktop.
import socket #引入lib
def print_machine_info(): #自訂副程式
host_name = socket.gethostname()
ip_address = socket.gethostbyname(host_name)
print("Host name: %s" %host_name)
print("IP address: %s" %ip_address)
if __name__ == '__main__': #main函式
print_machine_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment