Getting name of windows computer running python script? Getting name of windows computer running python script? python python

Getting name of windows computer running python script?


It turns out there are three options (including the two already answered earlier):

>>> import platform>>> import socket>>> import os>>> platform.node()'DARK-TOWER'>>> socket.gethostname()'DARK-TOWER'>>> os.environ['COMPUTERNAME']'DARK-TOWER'


import socketsocket.gethostname()