当前位置: 首页 > news >正文

常州市建设工程质监站网站企业网站排版

常州市建设工程质监站网站,企业网站排版,jsp做就业网站,石家庄电力设计公司文章目录 需求配置环节明确安装的是64位Python安装目录 创建Console C ProjectCpp 调用 Python Demo 参考 需求 接手了一个C应用程序#xff0c;解析csv和生成csv文件#xff0c;但是如果要把多个csv文件合并成一个Excel#xff0c;分布在不同的Sheet中#xff0c;又想在一… 文章目录 需求配置环节明确安装的是64位Python安装目录 创建Console C ProjectCpp 调用 Python Demo 参考 需求 接手了一个C应用程序解析csv和生成csv文件但是如果要把多个csv文件合并成一个Excel分布在不同的Sheet中又想在一次运行中完成不想说运行完C 的App后再调用一个Python脚本或程序这需要两步操作 配置环节 明确安装的是64位 根据安装的Visual Studio 的版本我安装的是64-bit的。 如何查看当前Python已安装的python位数或者版本 在cmd模式下输入python,可以看到已安装64bit版本 C:\Users\xxxpython Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information.C:\Users\xxxwhere python C:\Program Files\Python310\python.exe C:\Users\xxx\AppData\Local\Microsoft\WindowsApps\python.exePython安装目录 - python.h 所在目录 C:\Program Files\Python310\include python libraries 目录 C:\Program Files\Python310\libs 当设置Visual Studio工程属性时需要用到上述目录 创建Console C Project 创建一个工程然后配置工程属性 Cpp 调用 Python Demo 参考代码 #include Windows.h #include iostream #include string #include Python.husing namespace std;// https://docs.python.org/3/extending/embedding.html void CallPython(string PythonModuleName, string PythonFunctionName) {char* funcname new char[PythonFunctionName.length() 1];strcpy_s(funcname, PythonFunctionName.length() 1, PythonFunctionName.c_str());char* modname new char[PythonModuleName.length() 1];strcpy_s(modname, PythonModuleName.length() 1, PythonModuleName.c_str());printf(Hit any key to initialize the Python interpreter\n);system(pause);// Initialize the Python interpreter // https://docs.python.org/3/c-api/init.html#c.Py_InitializePy_Initialize();TCHAR cwd[2048];GetCurrentDirectory(sizeof(cwd), cwd);// Import a module. This is best described by referring to the built-in Python function __import__().// https://docs.python.org/3/c-api/import.html?highlightpyimport_importmodule#c.PyImport_ImportModule printf(Hit any key to Load the Python module %ws - %s\n, cwd, modname);system(pause);PyObject* my_module PyImport_ImportModule(modname);// Print a standard traceback to sys.stderr and clear the error indicator// https://docs.python.org/3/c-api/exceptions.html?highlightpyerr_print#c.PyErr_PrintPyErr_Print();printf(Module found\n);printf(Hit any key to find function %s from Python module %ws\n, funcname, cwd);system(pause);// Get the address of the particular Python function in the imported module// https://docs.python.org/3/c-api/object.html?highlightpyobject_getattrstring#c.PyObject_GetAttrStringprintf(Getting address of %s in Python module\n, funcname);PyObject* my_function PyObject_GetAttrString(my_module, funcname);PyErr_Print();printf(Function found\n);printf(Hit any key to call function %s from Python module %ws\n, funcname, cwd);system(pause);// Call a callable Python object callable, with arguments given by the tuple args. // If no arguments are needed, then args can be NULL.// https://docs.python.org/3/c-api/call.html?highlightpyobject_callobject#c.PyObject_CallObjectPyObject* my_result PyObject_CallObject(my_function, NULL);PyErr_Print();printf(Your function has been called\n);system(pause);// Undo all initializations made by Py_Initialize() and subsequent use of Python/C API functions, // and destroy all sub-interpreters (see Py_NewInterpreter() below) that were created and not yet // destroyed since the last call to Py_Initialize(). Ideally, this frees all memory allocated by the Python interpreter.// https://docs.python.org/3/c-api/init.html?highlightpy_finalize#c.Py_FinalizeExPy_Finalize();delete[] funcname;delete[] modname; }int main() {CallPython(PythonFile, helloworld);system(pause);return 0; } 上述代码编译通过后如果直接运行会Failed 原因是我们并没有定义PythonFile module.在Debug模式下生成的exe文件在x64目录下 创建PythonFile.py 文件 import re import stringdef helloworld():print(Hello from Python!)在main函数内 PythonFile 对应了 PythonModuleNamehelloworld 对应了 PythonFunctionName 运行Demo后的输出结果 Hit any key to initialize the Python interpreter 请按任意键继续. . . Hit any key to Load the Python module C:\Resource\App\Python\CppPython\CppPython - PythonFile 请按任意键继续. . . Module found Hit any key to find function helloworld from Python module C:\Resource\App\Python\CppPython\CppPython 请按任意键继续. . . Getting address of helloworld in Python module Function found Hit any key to call function helloworld from Python module C:\Resource\App\Python\CppPython\CppPython 请按任意键继续. . . Hello from Python! Your function has been called 请按任意键继续. . . 请按任意键继续. . .参考 C与Python混合编程
http://www.hkea.cn/news/14259005/

相关文章:

  • 中国建设银行上海分行信息网站网络设置的网站
  • 网站建设推广襄樊wordpress ent 主题
  • 怎样做网站地图盐城做网站优化
  • 做网站翻页怎么做遵义网页
  • 电商网站开发实战视频教程wordpress 站外搜索
  • 网站平台推广有哪些html5网站上线模版
  • 为什么网站开发要用架构网站建设与管理专业就业方向
  • 网站维护的协议头条发布视频成功显示404
  • 鄞州网站制作网站开发的项目总结
  • 有了网站源码怎么做网页vps主机访问网站
  • 足球比赛直播免费观看农产品网站建设及优化项目
  • 电影网站建设策划书北京小程序开发平台
  • wordpress本地站点地址如何配置陕西省住房与城乡建设厅网站
  • 洛阳免费提供建站方案商会网站建设开发
  • 建设工程信息网站有哪些东莞网站开发报价
  • 手机网站建设哪家好wordpress数据统计插件
  • 平面设计有哪些网站陕西seo经理
  • 做创意美食的视频网站有哪些阿里巴巴的网站架构
  • 网站备案跟做哪个推广有关系吗网站改版 百度影响
  • js 曲线 网站在线照片处理工具
  • 服装网站 欣赏app运营推广策划方案
  • 合肥制作网站的公司简介网络架构书籍
  • 怎么把自己做的网页上传网站湘潭做网站 就问磐石网络
  • 网站建设公司企业文化电商小程序开发多少钱
  • 网站如何宣传推广wordpress 电影解析
  • 工业设计招聘信息网站seo关键词排名优化方案
  • 泉州网站建设培训网页设计图片轮播效果
  • 巩义自助建站优化国内营销推广渠道
  • 长沙美容网站建设wordpress 好的主题
  • 坪山网站建设哪家效益快企业宣传册一般分几个模块