Tag: openstv

从C#调用Python应用程序/脚本

我正在构建一个ASP.NET MVC(C#)站点,我想在其中实现STV( Single Transferable Vote )投票 。 我之前使用OpenSTV进行投票,取得了巨大成功,但我从未以编程方式使用它。 OpenSTV Google Code项目提供了一个Python脚本 ,允许从其他应用程序使用OpenSTV: import sys sys.path.append(“path to openstv package”) from openstv.ballots import Ballots from openstv.ReportPlugins.TextReport import TextReport from openstv.plugins import getMethodPlugins (ballotFname, method, reportFname) = sys.argv[1:] methods = getMethodPlugins(“byName”) f = open(reportFname, “w”) try: b = Ballots() b.loadUnknown(ballotFname) except Exception, msg: print >> f, (“Unable to […]