[源碼]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