Created
March 4, 2019 05:29
-
-
Save p208p2002/85eec17297112e1a82090c1ba2c4e9f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| def get_remote_machine_info(): | |
| remote_host = 'www.python.org' #目標host | |
| try: #使用try except做例外處理 | |
| print ("IP address of %s: %s" %(remote_host, socket.gethostbyname(remote_host))) #印出結果 | |
| except socket.error as err_msg: #如果發生錯誤 | |
| print ("%s: %s" %(remote_host, err_msg)) #印出錯誤訊息 | |
| if __name__ == '__main__': | |
| get_remote_machine_info() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment