Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IronPython.Runtime.UnboundNameException:';全球名称';罪恶';未定义';错误_Python_Ironpython - Fatal编程技术网

IronPython.Runtime.UnboundNameException:';全球名称';罪恶';未定义';错误

IronPython.Runtime.UnboundNameException:';全球名称';罪恶';未定义';错误,python,ironpython,Python,Ironpython,当我试图使用数学函数sin时,IronPython脚本出现了问题 var pyForSrc = @"def Test(): return sin(a)"; 因为我试图执行上面的脚本,然后得到错误 IronPython.Runtime.UnboundNameException: 'global name 'sin' is not defined' 我试着用数学;但我得到了如下的错误 IronPython.Runtime.UnboundNameException

当我试图使用数学函数sin时,IronPython脚本出现了问题

var pyForSrc = @"def Test():
                 return sin(a)";
因为我试图执行上面的脚本,然后得到错误

IronPython.Runtime.UnboundNameException: 'global name 'sin' is not defined'
我试着用数学;但我得到了如下的错误

IronPython.Runtime.UnboundNameException: 'global name 'math' is not defined'.
当我尝试像数学一样添加时,我也会出错; 有人能帮助我如何将数学库添加到IronPython脚本中吗?

您应该写:

导入数学

在代码顶部

是否包含数学模块?很抱歉,如何包含数学模块。我了解到这个数学模块总是可用的。我正在使用IronPythonNuget package(v2.7.9)在代码顶部编写“导入数学”。