码迷,mamicode.com
首页 > 编程语言 > 详细

Python调用C++的DLL

时间:2016-10-08 19:47:12      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

import os
import sys
from ctypes import *

test = cdll.LoadLibrary(D:\Python27\py.dll)
print test.Add(1, 2)
test.Echo("hello dll")

mypath = sys.argv[1]
if not os.path.exists(mypath):
    print "The path %s does not exist!" % mypath
    sys.exit(2)

for f in [s for s in os.listdir(mypath) if os.path.splitext(s)[1] == ".csta"]:
    outputname = f + ".csv"
    test.Analyzer(os.path.join(mypath,f), os.path.join(mypath,outputname))
    print "%s >> %s" %(f, outputname)

程序思路:

  1. 调用cdll.LoadLibrary将dll导入进来;

  2. 32bit的dll在64bit的Python中无法使用;

Python调用C++的DLL

标签:

原文地址:http://www.cnblogs.com/cnpirate/p/5939446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!