[英]Calling a .Net function form python which takes an argument (passed by reference)
I am trying to invoke a .Net function from python using the Python.net module.我正在尝试使用 Python.net 模块从 python 调用 .Net 函数。 The existing code was written on Iron Python, I am in the process of converting the code base to Python 3.X version.现有代码是在 Iron Python 上编写的,我正在将代码库转换为 Python 3.X 版本。
Can somebody please help me with this?有人可以帮我解决这个问题吗? I am currently stuck at this point.我目前被困在这一点上。
The C# function: C# 函数:
public int waitforResult (out UInt32 Elapsed_time)
{
// Code snippet
}
IronPython code: IronPython 代码:
Elapsed_time = clr.Reference[System.UInt32](10000000) - (works fine in Iron Python)
Pyton.net code: Pyton.net 代码:
Elapsed_time = System.UInt32(10000000)
result = waitforResult(Elapsed_time)
It seems the wait time is not being considered似乎没有考虑等待时间
Thanks, Lipun谢谢,立邦
Python.NET bundles any out
parameters with the return value into a tuple. Python.NET 将带有返回值的任何out
参数捆绑到一个元组中。 So you need所以你需要
result, elapsed = waitforResult()
On a similar note, this is how you call Dictionary.TryGetValue
:类似地,这就是您调用Dictionary.TryGetValue
:
found, value = dict.TryGetValue(key)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.