我尝试使用IronPython脚本导入dateutil包,但收到错误add
。错误来自此文件:... \ Python36 \ Lib \ string.py。
我的脚本由来自Microsoft.Scripting.Hosting的unexpected token '='
类执行,它是这样的:
ScriptEngine
但是当我这样做时一切都很好:
import sys
sys.path.append(r'C:\Program Files\Python36\Lib')
sys.path.append(r'C:\Program Files\Anaconda3\Lib\site-packages')
from dateutil.parser import *
class PythonCaller():
def Call(self):
return parse('2000-01-01')
我的pythonExample文件是:
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "...\\Python36\\python.exe";
start.Arguments = "...\\Files\\pythonExample.py";
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
}
}
var a = s.ElapsedMilliseconds;
如何在import sys
sys.path.append(r'C:\\Program Files\\Python36\\Lib')
sys.path.append(r'C:\\Program Files\\Anaconda3\\Lib\\site-packages')
from dateutil.parser import *
print(parse('2000-01-01'))
文件中导入dateutil并在C#中通过ScriptEngine执行它?是否可以以这种方式导入外部python库?