【发布时间】:2021-01-01 23:10:42
【问题描述】:
我在运行 build.xml 文件时尝试从我的 ant build.xml 文件运行 python 程序,但我无法将参数传递给 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 程序
提前致谢!!!!!
【问题讨论】: