๐Ÿš€ Languege/Python

Python์—์„œ Hostname ํ™•์ธํ•˜๊ธฐ

mini_world 2021. 9. 27. 17:53
๋ชฉ์ฐจ ์ ‘๊ธฐ

์•„์ฃผ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค.

 import socket
 print(socket.gethostname())

(base) [root@ip-172-31-14-180 basicPubSub]# python3
Python 3.8.8 (default, Apr 13 2021, 19:58:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> print(socket.gethostname())
ip-172-31-14-180.ap-northeast-2.compute.internal
728x90