我试图将此VBScript代码转换为Python(Win32)代码但没有运气!VBScript到Python片段转换
Dim objMain, objSysInf, stMsg
Set objMain = CreateObject("nnetcom.oMain")
Call objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")
Set objSysInf = CreateObject("nnetcom.oSystemInfo")
Call objSysInf.GetSystemInfos
stMsg = objSysInf.cOsName & " " & objSysInf.cOsType & vbCrLf & _
objSysInf.cOsCpu & vbCrLf & objSysInf.cOsMem & vbCrLf & _
objSysInf.cOsGpu
MsgBox stMsg, vbInformation, "System Information"
Set objSysInf = Nothing
Set objMain = Nothing
我运行Windows 7 32位与的Python 2.7.3和的Python安装的Windows扩展。 此外,我从...... 执行“makepy.pyc”添加COM对象“LIB \站点包\ win32com \客户端\”并没有运气,总是得到一些错误信息......
这是我的Python代码:
import pythoncom
import win32com.client
objMain = win32com.client.Dispach("nnetcom.oMain")
ret = objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")
objSysInf = win32com.client.Dispach("nnetcom.oSystemInfo")
objSysInf.GetSystemInfos()
stMsg = objSysInf.cOsName
print(stMsg)
有没有人可以帮助我进行这个对话?
请显示完整的错误输出。 – Marcin 2012-04-22 13:14:52
**您好的Marcin ** 以下是错误输出: C:\> C:\ PROGRA〜1 \的Python \ python.exe C:\ example2.py 回溯(最近最后一次调用): 文件 “C:\ example2.py”,4号线,在 objMain = win32com.client.Dispach( “nnetcom.oMain”) AttributeError的: '模块' 对象有没有属性 'Dispach' 你能帮助我? ** Ragards,维克多** –
beic
2012-04-22 13:27:20