[英]Passing dictionary values in python as command line inputs to c++ code
I have a wrapper file that is reading a JSON file into a dictionary. 我有一个包装文件,正在将JSON文件读入字典。 I am using the os.system("command")
command to run a C++ code in this python file. 我正在使用os.system("command")
命令在此python文件中运行C ++代码。 The C++ code takes command line inputs which are key values in the parsed dictionary. C ++代码采用命令行输入,这些输入是已解析的字典中的键值。
How can i pass a python variable as a command line input for a C++ code using the os.system("command")
instruction? 如何使用os.system("command")
指令将python变量作为C ++代码的命令行输入传递?
You can't do that unless you relax one of the restrictions. 除非您放松其中一项限制,否则您将无法做到这一点。
Relax the python dict requirement: The command line has a well defined text arguments interface, which can easily handle all the info. 放松对python dict的要求:命令行具有定义明确的文本参数界面,该界面可以轻松处理所有信息。 You can pass the json filename, the str representation of the dict, or pass name-value pairs as command line arguments. 您可以传递json文件名,字典的str表示形式,或将名称-值对作为命令行参数传递。
Relax the system call requirement: Rather than building an executable from the c++ code, you can build a python c++ extension. 放宽对系统调用的要求:您可以构建python c ++扩展,而不是从c ++代码构建可执行文件。 The c++ code can export functions that take a python dict. C ++代码可以导出采用python字典的函数。
Relax the c++ requirement: Obviously you could code it in python. 放松对c ++的要求:显然,您可以使用python对其进行编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.