用户从命令行输入

时间:2019-12-18 18:54:39

标签: python python-3.x bash command-line

我必须制作一个从命令行这样调用的程序

T arow00[2], arow01[2], arow02[2]; // Each is array [2] of T
T arow10[2], arow11[2], arow12[2];
T arow20[2], arow21[2], arow22[2];
T arow30[2], arow31[2], arow32[2];
T *parow0[3] = { arow00, arow01, arow02 }; // Each is array [3] of pointer to T
T *parow1[3] = { arow10, arow11, arow12 };
T *parow2[3] = { arow20, arow21, arow22 };
T *parow3[3] = { arow30, arow31, arow32 };
T **ppa[4] = { parow0, parow1, parow2, parow3 }; // Array [4] of pointer to pointer to T
T ***pppa = ppa; // Pointer to pointer to pointer to T;

pppa[0][1][1] = foo;
// will set ppa[0][1][1] = foo;
// will set parow0[1][1] = foo;
// will set arow01[1] = foo; 

我能够像这样完成它,但是它仍然要求输入名称:

python3 hello.py <name>

1 个答案:

答案 0 :(得分:2)

您可以使用sys.argv Check the docs

import sys
print_hello(sys.argv[1])