logo

How to Get the PC Name in Python 📂Programing

How to Get the PC Name in Python

Code

You can obtain it with os.getlogin.

>>> import os
>>> os.getlogin()
'rydbr'

Environment

  • OS: Windows11
  • Version: Python 3.11.5