[英]What does (1,) mean in Python?
I looked at similar questions but I didn't find this topic anywhere.我查看了类似的问题,但在任何地方都没有找到这个话题。
I want to know what does the tuple (1,)
mean in Python?我想知道元组
(1,)
在 Python 中是什么意思?
From https://wiki.python.org/moin/TupleSyntax来自https://wiki.python.org/moin/TupleSyntax
One Element Tuples
一元元组
One-element tuples look like:
单元素元组如下所示:
1,
The essential element here is the trailing comma.
这里的基本元素是尾随逗号。 As for any expression, parentheses are optional, so you may also write one-element tuples like
对于任何表达式,括号是可选的,因此您也可以编写单元素元组,例如
(1,)
but it is the comma, not the parentheses, that define the tuple.
但定义元组的是逗号,而不是括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.