【发布时间】:2022-01-12 03:54:40
【问题描述】:
我对 python 比较陌生,我正在尝试与列表连接。这是我最好的尝试,但显然它不起作用。有人知道这样做的方法吗?谢谢
present = ["Jake", "Jimmy", "Karen"]
print("The people present are " + present)
【问题讨论】:
-
你想要发生什么?你想打印出人的名字吗?逗号分隔?您真的想要打印整个列表、括号和所有内容吗?
-
print("The people present are " + str(present))? -
感谢atline,这就是我想要做的一切:D
-
您也可以将多个参数传递给
print,例如print("The people present are", present)。print会自动将每个单独的参数转换为字符串。
标签: python concatenation