使用sys打印PHP变量时出现Python错误

2024-09-30 01:36:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经试着解决这个问题好几个小时了,但都没有成功。我搜索过类似的问题,但都没用

PHP文件-用Notepad++编写:

<?php
$item='example';
$tmp = shell_exec("C:\Python34\python.exe TestingStuff.py .$item");
echo $tmp;
?>

在浏览器(使用Apache)中运行此文件时,我将执行以下输出:

['TestingStuff.py', '.example'] .example

Python文件-以空闲方式编写:

#!c:\python34\python.exe

import sys 
print(sys.argv[1])

运行此命令时,我收到以下错误:

IndexError: list index out of range

运行print(sys.argv)时,输出为['C:/xampp/htdocs/TestingStuff.py']


Tags: 文件pyexamplesysshellitemexetmp

热门问题