What#39;s the difference between (1,) and (1) in Python(Python中的(1,)和(1)有什么区别)

本文介绍了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.

这篇关于Python中的(1,)和(1)有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!