M
M
Maxim Siomin2020-07-19 11:22:22
Python
Maxim Siomin, 2020-07-19 11:22:22

How to write a program in two languages?

I want to write part of the program in python and the other in c++. That type:

#include <iostream>

int main()
{
    int x;
    std::cin >> x;
}


And then this x must somehow be passed to python so that it can process it. Is it possible?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dr. Bacon, 2020-07-19
@MaxSiominDev

When will you learn how to google?
https://docs.python.org/3.8/extending/extending.html
https://habr.com/ru/post/469043/ plus there in the links different methods are considered

H
Hcuy, 2020-07-19
@Hcuy

You have tritely different file extensions, there’s nothing to do without external libraries, but I won’t vouch for their performance. You can write variables to json and read them in c++.

A
Andrey_Dolg, 2020-07-19
@Andrey_Dolg

There are many ways to organize IPC. =)

V
vladbaginsky, 2020-07-22
@vladbaginsky

The easiest way is to write the value of the variable to a txt file and read it in Python code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question