我是使用c#和python编程的新手
我正在将IronPython库用于Visual Studio
我遇到此问题:Microsoft.Scripting.SyntaxErrorException: "unexpected token ','"
,当我运行c#代码时。我想获取.py func的“ var”;
我的C#代码
ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
var searchPaths = engine.GetSearchPaths();
searchPaths.Add(@"C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/Lib/site-packages/");
searchPaths.Add(@"C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/Lib/");
engine.SetSearchPaths(searchPaths);
engine.ExecuteFile(@"C:/Users/VYashunin/source/repos/PythonApplication1/PythonApplication1/PythonApplication1.py", scope);
dynamic min = scope.GetVariable("minValue");
Console.WriteLine(min);
还有我的.py代码
# -*- coding: utf-8 -*-
from pyzabbix import ZabbixAPI
import sys
import os
sys.path.append(r"c:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib")
requestToZabbix = ZabbixAPI(url='http://192.168.1.22/zabbix/', user='admin', password='zabbix')
minValue = None
avgValue = None
maxValue = None
print("Подключение к Zabbix успешно. API Version %s" % requestToZabbix.api_version())
response = requestToZabbix.history.get(itemids=30171, time_from=1530403200,
time_till=1532995199,
history=0)
vals = [float(x['value']) for x in response]
minValue = min(vals)
print(minValue)
avgValue = round(sum(vals)/len(vals))
print(avgValue)
maxValue = max(vals)
print(maxValue)
这是什么,以及如何解决此问题?对不起,我的英文:)