Visual Studio 模板参数:机器名称大写吗?

发布于 2024-09-19 18:03:22 字数 355 浏览 2 评论 0原文

MSDN 模板参数

是 < code>$machinename$ 总是大写? 我想根据这个返回值编写一些代码,但是 Python 的 socket.gethostname() 返回“Mark-PC”,而 < code>$machinename$ 返回“MARK-PC”。如果是这样,我只需 .upper() 主机名,但我必须这样做似乎有点愚蠢。为什么不一致?

MSDN Template Parameters

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

话少心凉 2024-09-26 18:03:22

区别在于 $machinename$ 返回 NetBIOS 名称,而 socket.gethostname() 返回主机名。尽管 Windows 通常将它们命名为相同,但它们是不同的东西。从技术上讲,如果您更改 Windows 系统设置中的主 DNS 后缀,主机名 API 可能会返回不同的结果。 (此时它将是机器名称 + 后缀)

这是系统级别的,并非特定于 python,如等效的 C# API 所示:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文