python - 如何在 python 中获取我的电脑的 Windows 工作组名称
问题描述
我试图在 python 中找到我的工作组名称,有人知道这个函数吗?
解决方案
import wmi
wmi_os = wmi.Win32_ComputerSystem()[0]
print(wmi_os.Workgroup)
你也可以走得更远,看看print(wmi_os.__dict__['properties'].keys())
dict_keys(['AdminPasswordStatus', 'AutomaticManagedPagefile', 'AutomaticResetBootOption', 'AutomaticResetCapability', 'BootOptionOnLimit', 'BootOptionOnWatchDog', 'BootROMSupported', 'BootStatus', 'BootupState', 'Caption', 'ChassisBootupState', 'ChassisSKUNumber', 'CreationClassName', 'CurrentTimeZone', 'DaylightInEffect', 'Description', 'DNSHostName', 'Domain', 'DomainRole', 'EnableDaylightSavingsTime', 'FrontPanelResetStatus', 'HypervisorPresent', 'InfraredSupported', 'InitialLoadInfo', 'InstallDate', 'KeyboardPasswordStatus', 'LastLoadInfo', 'Manufacturer', 'Model', 'Name', 'NameFormat', 'NetworkServerModeEnabled', 'NumberOfLogicalProcessors', 'NumberOfProcessors', 'OEMLogoBitmap', 'OEMStringArray', 'PartOfDomain', 'PauseAfterReset', 'PCSystemType', 'PCSystemTypeEx', 'PowerManagementCapabilities', 'PowerManagementSupported', 'PowerOnPasswordStatus', 'PowerState', 'PowerSupplyState', 'PrimaryOwnerContact', 'PrimaryOwnerName', 'ResetCapability', 'ResetCount', 'ResetLimit', 'Roles', 'Status', 'SupportContactDescription', 'SystemFamily', 'SystemSKUNumber', 'SystemStartupDelay', 'SystemStartupOptions', 'SystemStartupSetting', 'SystemType', 'ThermalState', 'TotalPhysicalMemory', 'UserName', 'WakeUpType', 'Workgroup'])
其中一些可能对您有用
推荐阅读
- swift - Swift AVAudioPlayer 无法在某些设备上播放声音
- android - 如何使用 Flutter 和 Dart 将变量值发送到 API
- python - psycopg2 在日志中显示敏感信息
- java - 带有 In 和 Contains 的 Spring Boot JPA 功能
- tensorflow - 使用 ML/神经网络的简单概率问题
- python - 覆盖 Python 析构函数 (__del__) 会导致内存泄漏吗?
- json - 从 json 文件导入后,将字典的数据转换回其正确的数据类型
- migration - 如何从 rails6 中的 rake 文件迁移特定迁移
- rxjs - 是否可以在每个可观察到的完成上发出值,这些完成将使用单管道发送给订阅者?
- kubernetes - configmap 不适用于服务和 loadBalancerIP