I need to run C ++ - a program from the Django Framework. In a way, I get input from the user interface in views.py. When I have these inputs, I need to process the input using my C ++ program and use these results. Is it possible?
Compile this program in C ++ and call the module from python using subprocess
You can use swig to create a C ++ module that can be imported into python. An alternative is boost :: python (but personnaly, I prefer swig).
- os.popen. , ++ mycpp, - :
mycpp
results = os.popen('mycpp %s' % user_input).read()
, , os.popen . , , , Python 2.6 .
os.popen
, * nix, ++ - , /home/rishabh/myexe.
django :
import commands status, res = commands.getstatusoutput("/home/rishabh/myexe") # status contains process status (0 for success, non-zero for unsuccesful termination) and res contains the output of the process
Source: https://habr.com/ru/post/1729019/More articles:How to use CTE to match parent-child relationships? - sql-serverobjective-c форматирование кода - objective-cDjango General Relationship with Django Administrator - djangoSSO, Facebook connection, user merge - mergeregex - Replace all dots, special characters except file extension - c #Django - проектирование отношений моделей - интерфейс администратора и встроенный интерфейс - databaseYes / No in Javascript like this in StackOverflow? - javascriptSQL Server query: SELECT 1 WHERE EXISTS and SELECT TOP 1 1 - sqlRails find - the order of presence of the Paperclip application, and then the datetime creation record - ruby-on-railsImplementing an "excellent" choice in an existing query - sqlAll Articles