加深对打印多个变量的理解

时间:2019-01-10 14:12:22

标签: python python-3.x

对于以下Python脚本:

print("Mary had a little lamb.")
print("Its fleece was white as {}.".format('snow'))
print("And everywhere that Mary went.")

end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"

print(end1 + end2 + end3 + end4 + end5 + end6, end=' ')
print(end7 + end8 + end9 + end10 + end11 + end12)

我不确定这行代码片段的目的并为此感到挣扎:

print(end1 + end2 + end3 + end4 + end5 + end6, end=' ')

end=' '在这里实际上是做什么的?我们只是在声明一个变量并将其分配为空格吗?

脚本中包含end=' '时,输出为:

CheeseBurger

当我从脚本中删除end=' '时,输出为:

Cheese
Burger

请有人能彻底解释我的脚本中这小段end=' '代码在做什么吗?

0 个答案:

没有答案