我希望我的程序要求集合中至少有一个参数才能使参数有效。
因此,为了举例,假设我有3个开关(-a,-b和-c)和两个强制参数。
这些是有效的。
myapp -a FOO BAR
myapp -a -b FOO BAR
myapp -a -c FOO BAR
这不会是:
myapp FOO BAR
答案 0 :(得分:0)
您可以使用省略号tensor1=tf.squeeze(tensor1, axis=-1)
tensor2=tf.squeeze(tensor2, axis=-1)
来声明选项应出现一次或多次:
output = tf.expand_dims(tf.gather_nd(tensor2, indices), axis=-1)
tensor1= tf.expand_dims(tensor1, axis=-1)
tensor2= tf.expand_dims(tensor2, axis=-1)
我们在此声明,...
,Usage:
myapp (-a|-b|-c)... <FOO> <BAR>
或-a
应出现一次或多次。
接受:
-b
拒绝:
-c