zoukankan      html  css  js  c++  java
  • c# 调用python

    1.安装python2.7(我的安装目录为C:Python27)

    2.在python2.7的安装目录中,找到Lib文件夹,复制整个文件夹到项目中

    2.引用如下dll

    3.写如下代码

    using Hm.Common.InitPythonRuntime;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace
    {
        public class PythonUtil
        {
             private InitRuntime pythonRuntime=null;
             //python文件位置
             private readonly string PythonFilePath="....a.py"
             private readonly string DllPath=AppDomain.BaseDirectory+"Hammer.Common.dll";
             public bool AnalysisEndStr(string targetStr)
             {
                  if(pythonRuntime==null)
                      pythonRuntime=new InitRuntime();
                  pythonRuntime.loadPythonFile(DllPath,PythonFilePath);
                  dynamic obj=pythonRuntime.GetDPython();
                  return obj.callPthon("IsEndStr",targetStr);
             }    
        }
    }        
    View Code
  • 相关阅读:
    Linux 系统启动过程
    Linux启动U盘制作
    JSONP 教程
    JSON 使用
    JSON.stringify()
    JSON.parse()
    Apache模块开发指南-APR池
    [C++基础]goto的用法
    atexit()函数
    c++ good books
  • 原文地址:https://www.cnblogs.com/mrxiaohe/p/5717149.html
Copyright © 2011-2022 走看看