我正在尝试使用 IronPython 2.7 在 .NET 4.0 上使用 IronPython 执行此方法。我正在使用 Windows 7
import os
import re
import nltk
import urllib
import xapian
import sys
def getData(url):
try:
html = urllib.urlopen(url)
text = html.read()
html.close()
except:
return "error"
try:
return nltk.clean_html(text) #takes the tokens
except:
return text
C#代码:
public static object Execute()
{
string scriptPath = "Calculator.py";
ScriptEngine engine = Python.CreateEngine();
engine.SetSearchPaths(new string[] { "c:\\Python26\\lib","c:\\Python26\\lib\\site-packages",
"C:\\IronPython-2.7\\Lib\\site-packages","C:\\IronPython-2.7\\Lib"});
ScriptSource source = engine.CreateScriptSourceFromFile(scriptPath);
ScriptScope scope = engine.CreateScope();
ObjectOperations op = engine.Operations;
source.Execute(scope);
dynamic Calculator = scope.GetVariable("Calculator");
dynamic calc = Calculator();
return calc.getData("http://www.wowebook.com/dot-net/ironpython-in-action.html");
}
有人可以告诉我我做错了什么吗?我一直说我没有 fcntl 模块