python 实现c++/c调用
详情可以查看:https://blog.youkuaiyun.com/l_xzmy/article/details/82183613
//编译C++,一定要加extern “C”,注意C为大写,小写会无法识别
import os
import ctypes
time_point = '2019-04-02 05:30:58'
weight = 80
def run_img_cut(weight, time_point):
print("Success:200")
if weight == 80:
weight = 2
else:
weight = 6
year = int(time_point[0:4])
month = int(time_point[5:7])
day = int(time_point[8:10])
hours = int(time_point[11:13])
minute = int(time_point[14:16])
second = int(time_point[17:19])
base_dir = 'Desktop/Photo/'
pic_name =''.join(['0', '0', str(weight), str(year), month, day, hours, minute, second])
pic_path_name = os.path.join(base_dir, pic_name+'.png') # 图片存储的名字
if os.path.exists(pic_path_name): # 判断文件是否存在
return 0
else:
cur = ctypes.cdll.LoadLibrary
save_img = cur('Desktop/test/test3.dll')
pic_path = save_img.max(year, month, day, hours, minute, second, weight)
return pic_path
注:如果想调用so文件,可直接把dll路径换一下。