我试图通过在Python程序中使用Rant procedural text generatorPython.NET. 我使用Rant主网站上的documentation的示例代码来测试它。我可以将Rant类导入到Python程序中,但是当我进入示例的rant.Do(pgm)
部分时,整个程序就会崩溃。在
我的代码有点像这样(我主要是通过Python命令行解释器来完成的):
import clr
import System
lib_dir = '/path/to/Rant.dll'
clr.AddReference(lib_dir)
from Rant import RantProgram
from Rant import RantEngine
from Rant import RantProgramArgs as args
rant = RantEngine
pgm = RantProgram.CompileString('[numfmt:verbal][rep:10][sep:,\s]{[rn]}')
# Here's where the program occurs.
output = rant.Do(pgm)
当我试图在对象rant
中使用Do()
方法时,就会出现问题。当我运行这个时,它给出错误TypeError: No method matches given arguments
。我研究了this question,因为它建议为该方法放入所有参数。在
Do()
方法的方法参数包括以下内容(这是我通过调用help(RantEngine)
得到的):
我试过用第一个。所以我试着调用这样的方法:
rant.Do(pgm, System.Int32(1), System.Double(2), args)
遗憾的是,它仍然给我一个TypeError
。在
那么如何让示例代码在Python下运行呢?在
目前没有回答
相关问题 更多 >
编程相关推荐