小编Sho*_*rV4的帖子

如何在 python 中解压(取消列出)没有 for 循环的列表?

假设我有一个变量 a,其中有一个列表,它看起来像这样:

a = ['hello', 'there']
Run Code Online (Sandbox Code Playgroud)

我想解压列表,但我不想使用 for 循环,但我只是不知道如何使其工作。我试过了:

def unpack(table):
    for i in table:
        return i


a = ['hello', 'there']

print(unpack(a))
Run Code Online (Sandbox Code Playgroud)

我想要打印它

hello, there
Run Code Online (Sandbox Code Playgroud)

但它只打印 hello 有人可以帮我吗?

但它只返回你好

python

0
推荐指数
1
解决办法
8020
查看次数

标签 统计

python ×1