简体   繁体   English

使用字符串时如何使用 *args

[英]how do I use *args when working with a string

I tried to use the *args when working with a list of strings and the output remained a tuple.我在处理字符串列表时尝试使用 *args,而 output 仍然是一个元组。 I'm trying ensure that all letters in the string are uppercase but I cant figure it out I tried tuple unpacking but it doesn't work on an indefinite number of objects我试图确保字符串中的所有字母都是大写的,但我无法弄清楚我尝试了元组解包,但它不适用于无限数量的对象

*args is used to pass variable number of arguments to a function. Here's a reference article: https://www.geeksforgeeks.org/args-kwargs-python/ *args用于将arguments的可变数传递给function。参考文章: https://www.geeksforgeeks.org/args-kwargs-python/

As far as working with a function that has a *args of strings, since *args groups its arguments into a tuple, you would need to access and operate on each string individually.至于使用具有 *args 字符串的 function,由于 *args 将其 arguments 分组到一个元组中,因此您需要单独访问和操作每个字符串。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM