开发者

Visual Studio Template Parameters: Machine Name Capitalized?

开发者 https://www.devze.com 2023-01-16 13:13 出处:网络
MSDN Template Pa开发者_StackOverflowrameters Is $machinename$ always capitalized? I wanted to write some code based on this return value, but Python\'s socket.gethostname() returns \"Mark-PC\" wherea

MSDN Template Pa开发者_StackOverflowrameters

Is $machinename$ always capitalized? I wanted to write some code based on this return value, but Python's socket.gethostname() returns "Mark-PC" whereas $machinename$ returns "MARK-PC". If so, I'll just .upper() the hostname, but it seems kinda dumb that I should have to do this. Why the inconsistency?


The difference is that $machinename$ returns the NetBIOS name, and socket.gethostname() returns the host name. They are different things even though Windows usually names them identically. The host name API can technically return a different result if you change the Primary DNS suffix in your Windows system settings. (At which point it will be machine name + the suffix)

This is system level and not specific to python as illustrated by the equivalent C# APIs:

System.Net.Dns.GetHostName()  --> method would return Mark-PC
Environment.MachineName    --> property would return MARK-PC
0

精彩评论

暂无评论...
验证码 换一张
取 消