如何在使用“*”解包列表之前打印字符串

How to print a string before using "*" to unpack list

解包元组时是否可以在使用 * 运算符之前打印字符串:

m = ['b', 'a', 'e']
print(*m, sep = ',')

b, a, e

我尝试在它之前打印一些东西:

print("String: " + *m, sep = ",")

我想要的输出是:

String: b, a, e

是否可以在这之前打印一个字符串,正确的语法是什么?

我想你可以使用

print(",".join(m))

尝试使用此代码:

print(",".join(m))

*m 将列表 m 解压缩为单独的参数。相当于:

print('b', 'a', 'e')

您可以在此之前和之后添加其他参数:

print('string', *m, sep=',')

is it possible to print that without the comma being after the string, and only having the comma apply to the items in the list?

任你选:

print(f'String: {", ".join(m)}')

print('String:', ', '.join(m), sep=' ')

print('String:', end=' ')
print(*m, sep=', ')