logo

How to Check the PC Name in Python 📂Programing

How to Check the PC Name in Python

Code

Use socket.gethostname().

>>> import socket
>>> socket.gethostname()
'lab1'

See Also

Environment

  • OS: Windows11
  • Version: Python 3.11.5