Python中的(1,)和(1)有什么区别
问题描述
如标题所述,我发现(1)
和(1,)
是不一样的.但是它们有什么区别呢?
As stated in the title, I found that (1)
and (1,)
are different. But what's the difference of them?
In[39]: (1) == (1,)
Out[39]: False
解决方案
逗号使它成为一个元组.(1) 与用分隔符包裹的 1 相同.
The comma makes it a tuple. (1) is just the same as 1 wrapped in delimiters.
相关文章