[text] How can use Python to get the system hostname Asked 9 years 8 months ago Active 1year 4 months ago Viewed 525k times Im writing a chat program for a local network. would like be able to identify computers and get the userset computer name with Python. 698 python hostname share edit follow flag edited Sep 1316 at 1600 asked Nov 24 10 2t 2133 ttay Grudev John 5455 04 039 076 129K 10 40 63 2dd a comment start a bounty 11 Answers Active Oldest Votes Use socket and s gethostnane. functionality. This will get the hostname of the computer where the Python interpreter is running 1064 inport socket printsocket. gethostnane V share edit follow flag edited Feb 1015 at 2302 answered Nov 24 10 at 2136 the TinMan Alex 146Kk 30 192 0272 558K 045 o 143 o 174 70 well thats not correct. It works for me offline and in home but now am a office and this retumns a different host name. DataGreed Jun 2112 a1 1339
in Backend, Javascript, Linux, Programming, Python