【问题标题】:php: call python script with "*" as argumentphp:使用“*”作为参数调用python脚本
【发布时间】:2017-05-01 12:23:24
【问题描述】:

我正在尝试通过 php 调用 python 脚本,但其中一个参数被作为参考传递?我想传递"*",但是当它到达python脚本时,它变成了"attempt.php",这是我的php文件名。我怎么能解决这个问题只通过"*" 这是我发送的代码(有 3 个变量,其中一个是 "*"

$python = `python test.py $a $b $c`;

【问题讨论】:

  • @KDOT 这并没有说明如何防止通配符被扩展。

标签: php python arguments call


【解决方案1】:

* 是 shell 中的通配符,您需要对其进行转义。使用escapeshellarg

$aesc = escapeshellarg($a);
$besc = escapeshellarg($b);
$cesc = escapeshellarg($c);
$python = `python test.py $aesc $besc $cesc`;

【讨论】:

    猜你喜欢
    • 2019-06-07
    • 2014-07-17
    • 2011-11-30
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多