gpt4 book ai didi

c# - 在嵌入式 IronPython v2 中获取最后一条语句结果

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:08 25 4
gpt4 key购买 nike

This post in Mike Stall's blog指出

The last expression result is stored as the global variable "_", so you can retrieve it like so:

object o = m_python.GetVariable("_");

但是目前在v2范围内执行后没有这样的变量,例如

scriptEngine.CreateScriptSourceFromString("a=1+2;a+1", SourceCodeKind.Statements);

有没有办法在不显式定义变量的情况下访问结果(a+1)

最佳答案

我怀疑对于 IronPython 2,您需要使用 SourceCodeKind.Interactive。

我稍后会尝试一下,看看是否可行。

关于c# - 在嵌入式 IronPython v2 中获取最后一条语句结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1966421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com