Skip to content Skip to sidebar Skip to footer

Python Code Snippet To Be Used In Php

I am a Microsoft developer then I explain what I want to do in those words to everybody to understand the question better. I have a Python piece of code which I need to make a litt

Solution 1:

The solution is to use exec()

So if you made your Python code to accept the input as an argument using

importsysmyPythonInputVar= sys.argv[1]

then you can feed it as in input argument to the line that you want to execute in the syntax form below in PHP

<html><body>
   Your Python code returns: 
       <?phpecho exec("/usr/bin/python /home/myUsername/test.py $myInput");?></body></html>

Post a Comment for "Python Code Snippet To Be Used In Php"