为什么连接时分隔符不起作用?

问题描述 投票:0回答:0

使用带有+或*的打印函数时,无法使用sep参数。

例如:

print("panda", "panda", sep=", ")

给:

熊猫,熊猫

然而

使用

print("panda" + "panda", sep=", ")

print("panda" * 2, sep=", ")

给:

熊猫熊猫

为什么?

我知道,答案可能是“因为 Python 就是这样设计的”。但更深层次的解释是什么?

python concatenation
© www.soinside.com 2019 - 2024. All rights reserved.