问题
I have a Python scrirpt and that I am trying to execute from C# code using IronPython
and I am getting the below error message:
Microsoft.Scripting.SyntaxErrorException: 'unexpected token '=''
Here is my Python code:
import logging
logging.basicConfig(filename='c:\\rahul\\example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
BUCKET_NAME='Rahul'
print("Bucket name :-" + BUCKET_NAME)
And here is my .NET C# code:
var engine = Python.CreateEngine();
var searchPaths = engine.GetSearchPaths();
searchPaths.Add(@"C:\Users\rahul\appdata\Local\Programs\Python\Python37-32\Lib");
engine.SetSearchPaths(searchPaths);
var scope = engine.CreateScope();
ScriptSource source = engine.CreateScriptSourceFromFile(filePath);
var compiled = source.Compile();
var result = compiled.Execute(scope);
I am getting an error from the last line :
Microsoft.Scripting.SyntaxErrorException: 'unexpected token '=''
Any help?
来源:https://stackoverflow.com/questions/53535931/ironpython-microsoft-scripting-syntaxerrorexception-unexpected-token