[JAVA/PYTHON] Command Line Argument | String[] args | sys.argv
2021-01-07 13:29
标签:span ble ++ ack cond system amp com pre JAVA terminal输入: 输出结果: PYTHON sys.argv Argument varible terminal 中输入: 输出结果 [JAVA/PYTHON] Command Line Argument | String[] args | sys.argv 标签:span ble ++ ack cond system amp com pre 原文地址:https://www.cnblogs.com/profesor/p/12969597.htmlpublic class Args
{
public static void main(String[] args)
{
// for (String arg : args)
// System.out.println(arg);
//或者下面的遍历方法
for (int i = 0; i )
System.out.println(args[i]);
}
}
javac Args.java && java Args jerry elaine george kramer
jerry
elaine
george
kramer
import sys
# unpacking
scriptName, first, second, third, fourth = sys.argv
print("type(sys.argv) = " + str(type(sys.argv))) #可以看出sys.argv的类型就是个list
print("scriptName = " + scriptName)
print(first)
print(second)
print(third)
print(fourth)
print()
#遍历列表
for item in sys.argv:
print(item)python3 Sys.py jerry elaine george kramer
type(sys.argv) =
文章标题:[JAVA/PYTHON] Command Line Argument | String[] args | sys.argv
文章链接:http://soscw.com/index.php/essay/40709.html