Passing value from PHP script to Python script

前端 未结 2 1767
温柔的废话
温柔的废话 2020-12-05 03:09

I looked at the other questions similar to this one, but can\'t figure this out still.

I have a basic php file that does this:


?php
$item=\'example\         


        
2条回答
  •  被撕碎了的回忆
    2020-12-05 03:24

    Although netcoder pretty much gave you the answer in his comment, here's an example:

    Python->PHP

    example.py

    import os
    os.system("/usr/bin/php example2.php whatastorymark")
    

    example2.php

    
    

    PHP->Python

    
    

    testscriptphp.py

    import sys
    print sys.argv[1]
    

    Here's how PHP's command line argument passing works: http://php.net/manual/en/reserved.variables.argv.php The same for Python: http://docs.python.org/library/sys.html#sys.argv

提交回复
热议问题