如何启动一个Windows应用程序,如记事本使用Python NET?这是蟒蛇2.7.13我的源代码:Python NET启动一个Windows应用程序
C:\Python27>python.exe
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> import System
>>> type = System.Type.GetTypeFromProgID("Notepad.Application")
>>> System.Activator.CreateInstance(type)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
System.ArgumentNullException: Value cannot be null.
Parameter name: activationContext
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
您可以检查如果'type'不是'None'?你确定ProgID =“Notepad.Application”吗?它为我返回null。 ''''也是Python中的保留关键字。 – denfromufa
这是一个古老的例子,我认为是内部python错误与这个包的新版本System和实例化方式。 –
我不理解你 – denfromufa