python获取节点内容
In Python, how to get the hostname of the node?
在Python中 ,如何获取节点的主机名?
In Python, you can get the hostname by the
library function in the
socket.gethostname()socket
module:
在Python中 ,您可以通过
socket .gethostname()
中的库函数
socket .gethostname()socket
模块 :
import socket
hostname = socket.gethostname()
Example:
例:
$ python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostname()
'host001'
Answered by dtivl.
dtivl回答。
翻译自: https://www.systutorials.com/how-to-get-the-hostname-of-the-node-in-python/
python获取节点内容