Python Glossary Русский

all Python 3platformfunction

platform.node()

system and machine

The computer's network name (hostname) as a string; an empty string if it cannot be determined.

Syntax

platform.node()

The name is not necessarily fully qualified: usually it is a short 'laptop' rather than 'laptop.example.com'; use socket.getfqdn() for the full name. The value is cached for the whole process, so a hostname change at runtime goes unseen until platform.invalidate_caches() is called (3.14+). Inside containers it is often a random ID.

Examples

import platform
print(platform.node())  # → ? имя машины, например my-laptop
print(platform.node() == platform.uname().node)  # → True — это одно и то же поле

See also

Open in the full glossarydocs.python.orgReport an inaccuracy