Reputation: 100
So I'm trying to figure out if i can get the variables that i make in Php file and use it in my Python file.
I've read that you can use this.
Php file:
$data='12';
$output=shell_exec("python pythonfile.py $data");
echo $output;
Python file:
import sys
print sys.argv[1]
And if i run the Php it will display 12
But what i want is to run it in Python, it's like I'll call $data
in python and manipulate it like make it float number. Is this possible?
Upvotes: 0
Views: 88
Reputation: 1148
A common and easy way to share data accross multiple process using different languages is to use sharable system resources. By exemple you could serialize data in a file and read the file from the other process. You can also use networks via sockets but it is more complicated.
Upvotes: 1
Reputation: 3733
You should call your PHP script from your Python script, you can use subprocess module, and many other ways
import subprocess
subprocess.call("php /path/to/your/script.php")
Here have good example, and many others have in Google.
Upvotes: 1