How do I get my computer's fully qualified domain name in Python?

偶尔善良 提交于 2019-11-27 03:01:46

问题


I know I can use platform.node() to get my computer's network name:

>>> import platform
>>> platform.node()
'MyComputerName'

But what I really want is something that will work similar to the following:

>>> get_full_network_domain_name()
'MyComputerName.it.na.mycompany.com'

Does something like this exist?


回答1:


The fully qualified domain name is returned by socket.getfqdn().



来源:https://stackoverflow.com/questions/11580023/how-do-i-get-my-computers-fully-qualified-domain-name-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!