Getting name of windows computer running python script? -


Actually, I have some Windows computers on my network that need to run a dragon script. Depending on which computer is running this script, a separate configuration option should be used in the script.

How do I get that computer name in Python script?

Assume that the script was running on a computer called Dark-Tower, I would like to write something like this:

  & gt; & Gt; & Gt; 

"post-text" itemprop = "text">

It has been found that there are three options (including both already answered):

  & gt; & Gt; & Gt; Import platform & gt; & Gt; & Gt; Import socket & gt; & Gt; & Gt; Import OS & gt; & Gt; & Gt; Platform.node () 'Dark Tower' & gt; & Gt; & Gt; Socket.gethostname () 'DARK-TOWER' & gt; & Gt; & Gt; Osvenver ['Computer'] 'Dark Tower'  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -