[源码]Python调用C# DLL例子(Python与.Net交互)


K8Cscan C# DLL例子代码

namespace CscanDLL 
{  
    public class scan  
    {  
        public static string run(string ip)  
        {  
            if (string.IsNullOrEmpty(ip))  
                return "";  
            else  
                return ip;		
        }  
    }  
}

 

Python 调用C#  DLL代码

import clr #pythonnet

print('python call K8Cscan c# dll')

clr.FindAssembly('netscan.dll')

clr.AddReference('netscan')

from CscanDLL import * 
print(scan.run('192.168.1.1'))

 

编译好的DLL

https://github.com/k8gege/K8CScan/blob/master/Example/DLL/c%23/netscan.dll

实战参考: https://www.cnblogs.com/k8gege/p/10852832.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM