[源碼]Python調用C# DLL例子(Python與.Net交互)

K8Cscan C# DLL例子代碼html

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

 

Python 調用C#  DLL代碼python

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'))

 

編譯好的DLLgit

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

實戰參考: http://www.javashuo.com/article/p-shwptfxn-hy.htmlc#

相關文章
相關標籤/搜索