无法将参数从 ant build.xml 文件传递​​给 pythonscript。我怎样才能传递价值?

Unable to pass parameters to pythonscript from ant build.xml file. How can i pass the value?

我正在尝试从我的 ant build.xml 文件 运行 一个 python 程序,当 运行 连接 build.xml 文件时我无法传递参数到 python 脚本

Python 检查给定数字阶乘的程序:

fact.py

#!/usr/bin/python

def factorial(num):
    if num == 1:
        return num
    else:
        return num * factorial(num - 1)

 num = int(input('Enter a Number: '))
 if num < 0:
     print 'Factorial cannot be found for negative numbers'
 elif num == 0:
     print 'Factorial of 0 is 1'
 else:
     print ('Factorial of', num, 'is: ', factorial(num))

build.xml 文件如下所示:

<project name="ant_test" default="python" basedir=".">
<target name="python" >
        
        <exec dir="D:\app\python" executable="D:\app\python\python.exe" failonerror="true">
            <arg line="D:\app\ant-workout\fact.py/>
        </exec>
</target>

当 运行 将 build.xml 归档时,它 运行 是 fact.py python 程序,它期待用户输入来检查阶乘给定的数字 .

如何将数字从 ant build.xml 文件

传递给 python 程序

提前致谢!!!!!

根据 documentation

Note that you cannot interact with the forked program, the only way to send input to it is via the input and inputstring attributes. Also note that since Ant 1.6, any attempt to read input in the forked program will receive an EOF (-1). This is a change from Ant 1.5, where such an attempt would block.
(emphasis mine)

那你能做什么?提供以下之一:

input
A file from which the executed command's standard input is taken. This attribute is mutually exclusive with the inputstring attribute.

inputstring
A string which serves as the input stream for the executed command. This attribute is mutually exclusive with the input attribute.


示例:

<project name="ant_test" default="python" basedir=".">
<target name="python" >
        
        <exec dir="D:\app\python" executable="D:\app\python\python.exe" 
                                  failonerror="true" 
                                  inputstring="42">
            <arg line="D:\app\ant-workout\fact.py/>
        </exec>
</target>