Python 有没有办法从未打包的列表中删除空格?

Python 有没有办法从未打包的列表中删除空格?,python,Python,我用random和string方法创建了一个列表,它的作用是创建一个大写字母,然后打印6个小写字母 现在,它总是在字符之间创建一个空格,如何删除空格 示例: mport random import string randomProfile = [random.choice(string.ascii_uppercase)] + random.choices(string.ascii_lowercase, k=6) print(*randomProfile) # unpack the list

我用
random
string
方法创建了一个列表,它的作用是创建一个大写字母,然后打印6个小写字母

现在,它总是在字符之间创建一个空格,如何删除空格

示例:

mport random
import string

randomProfile = [random.choice(string.ascii_uppercase)] + random.choices(string.ascii_lowercase, k=6)

print(*randomProfile) # unpack the list
W t o v s q j
输出示例:

mport random
import string

randomProfile = [random.choice(string.ascii_uppercase)] + random.choices(string.ascii_lowercase, k=6)

print(*randomProfile) # unpack the list
W t o v s q j
是的,我们可以用

"".join(randomProfile)

str.join(iterable)
通过给定的“胶水”字符串
str
连接
iterable
的元素,在我们的例子中该字符串为空。

print(*randomProfile,sep='')或
'.join(randomProfile)
但为什么会发生这种情况,为什么要在字符之间创建一个空格,因为
print
添加了空格作为分隔符。