【发布时间】:2016-05-27 07:38:02
【问题描述】:
我尝试将字符串作为命令行参数发送到我的 python 脚本,如下所示:
var cmdToBeExecute = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\myScript.py";
var start = new ProcessStartInfo
{
FileName = "C:\\Python27\\python.exe",
Arguments = string.Format("{0} {1}", cmdToBeExecute, "Rahul done good"),
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
我尝试读取命令行参数并在 python 中显示为:
import sys
print sys.argv[1]
但是,我只得到第一个单词“Rahul”作为输出。 请帮助我将字符串作为命令参数参数发送到我的 python 脚本。
【问题讨论】:
-
其他在
sys.argv[2]和sys.argv[3]尝试将它们全部打印出来。例如,您可以使用 for 循环
标签: c# python python-2.7 command-line-arguments processstartinfo