I
I
Igromik2020-07-01 21:31:26
Python
Igromik, 2020-07-01 21:31:26

How to get PC name in Python?

It seems that you can find out using the os library

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Ronald McDonald, 2020-07-01
@IgromikBot

import socket
print(socket.gethostname())

I
Ivan Solomennikov, 2020-07-01
@ivsol

import platform
print(platform.node())

A
Alan Gibizov, 2020-07-01
@phaggi

import os
print(os.uname()[1])

D
Denis Pablo, 2020-07-01
@fl3xice

You can use the standard os library
os.getusername()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question