Python get device-name

user8143636 picture user8143636 · Sep 9, 2017 · Viewed 9.6k times · Source

im not new in Python but I have one question left: How do I get the name of the Computer that im on/Device ? I tried many things, this is the last thing, I was in the os Module and found something but if i start the script, it gives me an error that in the os module isn't a 'getDeviceName' function.

from os import *

os.getDeviceName()

Answer

Tim picture Tim · Jul 4, 2018
import socket
socket.gethostname()

would also work just fine.