35: Python Program to find the System Hostname


Question: Write a program in Python to find the System Hostname.

Solution:

import socket

device_hostname = socket.gethostname()

print(device_hostname)
Output:
Python-get-System-Hostname-Google-Colab
Python-get-System-Hostname-mac

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap