使用 print(i, j)
和 print(i)
的两个设置返回相同的结果。在某些情况下,应该使用一个而不是另一个,或者可以互换使用它们是否正确?
desc = {'city': 'Monowi', 'state': 'Nebraska', 'county':'Boyd', 'pop': 1}
for i, j in desc.items():
print(i, j)
for i in desc.items():
print(i)
for i, j in desc.items():
print(i, j)[1]
for i in desc.items():
print(i)[1]
原文由 ZrSiO4 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果在打印中删除括号,两者都是不同的,因为您使用的是 python 2X
输出