简体   繁体   English

我如何选择一个特定的参数来使用* args处理?

[英]How can i select a specific argument to handle using *args?

In my last question the answer helped me solve an issue of choosing Number against other arguments. 在我的最后一个问题中 ,答案帮助我解决了选择Number反对其他论点的问题。

Then out of curiosity I though what if I actually had to use char2 or char1 or char3 etc.. without referring to a list that'll let me use them based on their placement in the argument. 然后出于好奇,虽然我实际上必须使用char2char1char3等。如果不参考允许我根据其在参数中的位置使用它们的列表,该怎么办。

The best way I could find after some research is creating a dynamic array for the arguments where each argument is an object in 1 class dedicated for that purpose, and actually separate them based on their object distinction. 经过研究后,我发现的最佳方法是为参数创建动态数组,其中每个参数都是专用于该目的的1类对象,并根据它们的对象区别实际上将它们分开。 That being said couldn't find any examples to clarify that method or walk me through the process step by step. 话虽如此,找不到任何示例来阐明该方法,也无法逐步引导我完成整个过程。

So I'd like to get ways on how to solve that issue and walking through the process. 因此,我想获得有关如何解决该问题并逐步完成该过程的方法。

So if I'm understanding you correctly: 因此,如果我正确地理解了您:

You want to pass char2,char1,char3 to your function and process this input not in terms of position, like you did with args, but in terms of "names". 您想将char2,char1,char3传递给函数,并且不像在args中那样在位置方面而是在“名称”方面处理此输入。 The solution are **kwargs . 解决的办法是**kwargs What do they do ? 他们在做什么 ? A good Explanation might be given here . 这里可能给出一个很好的解释。

If this doesn't solve your problem or doesn't even fit for the question please clearyfy your question. 如果这不能解决您的问题或什至不适合该问题,请清除您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在使用ipdb时如何获取方法的“args”参数值? - How can I get method's “args” argument value in while using ipdb? “-i”参数可以在你的程序中被“args.interface”引用,“-p”参数可以被引用为“args.port” - “-i” argument can referenced in your program by “args.interface” and the “-p” argument can be referenced as “args.port” 如何在python中使用selenium选择具有特定`title`的元素 - How can I select an element with a specific `title` using selenium in python 如何使用 Python 从表中获取 select 特定值? - How can I select specific values from a table using Python? 如何使用'* args'定义'do_twice'函数? - How can I define a 'do_twice' function with using '*args'? 关键字参数“args”干扰 JSON 数据转换。 我该如何处理? - Keyword argument 'args' interfering with JSON Data Conversion. How can I deal with this? 它如何获取列表列表中的特定参数? - How can it taken the specific args in lists of list? 我们如何从 args 和 kwargs 打印参数列表? - How can we print the argument-list from args and kwargs? 如何同时使用 args 和 Question 参数 - How do I use the args and Question argument at once 使用* args时参数传递 - Argument passing when using *args
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM