Get the hostname

Fredrik Lundh fredrik at pythonware.com
Wed Aug 6 07:26:47 EDT 2003


Lukas Schnieper wrote:

> How can i get the hostname of my Linux PC?
> I tried os.system('hostname') but i cant save the hostname in a variable
>   like hostname = os.system('hostname')

how about

    import socket
    hostname = socket.gethostname()

</F>








More information about the Python-list mailing list