如何在Python中将列表的整数项作为字符串参数传递给函数?

alw*_*btc 2 python string arguments list

我有一个由整数组成的Python列表:

a = [1, 2, 3]
Run Code Online (Sandbox Code Playgroud)

我想将此列表的项目作为参数传递给函数,它们必须是字符串:

myfunc("1", "2", "3")
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

Kar*_*tel 11

所以...我们使用*运算符将序列用作函数调用的多个参数; 我们想将每个参数转换为字符串.转换最明显,只需将值传递给内置函数即可完成str; 然后我们可以map将转换功能放到列表中.这些都是基本技术,我们所要做的就是将它们组合在一起:

myfunc(*map(str, a))
Run Code Online (Sandbox Code Playgroud)