Skip to main content
 首页 » 编程设计

python之IronPython 在 IronPython 控制台中实例化类时遇到问题

2025年05月04日17www_RR

我正在尝试学习 IronPython。我创建了一个像这样的非常简单的类:

class Test: 
  def testMethod(self): 
    print "test" 

接下来我尝试在 IronPython 控制台中使用它:

>>> import Test 
>>> t = Test() 

在第二行之后我得到以下错误:

TypeError: Scope is not callable

我做错了什么?

请您参考如下方法:

您需要from filename import Test,其中filename 是保存Test 的文件类的基本名称。

例如:Test类保存在test.py

然后:

from test import Test 
t = Test() 

将按预期运行。