此权限被拒绝的问题已解决。。已经授予了权限,但我在popen函数中添加了“env python”。。现在,代码正在按预期运行。。
add_shortcode( \'run_test_py\', \'test_py\' );
function test_py( $attributes )
{
$data = shortcode_atts(
[
\'file\' => \'test.py\'
],
$attributes
);
$handle = popen(\'env python \'. __DIR__ . \'/\' . $data[\'file\'] . \' 2>&1\', \'r\' );
$read = \'\';
while ( ! feof( $handle ) )
{
$read .= fread( $handle, 2096 );
}
pclose( $handle );
return $read;
}