(1,) 在 Python 中是什么意思? [英] What does (1,) mean in Python?
本文介绍了(1,) 在 Python 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看过类似的问题,但在任何地方都没有找到这个主题.
I looked at similar questions but I didn't find this topic anywhere.
我想知道元组 (1,)
在 Python 中是什么意思?
I want to know what does the tuple (1,)
mean in Python?
推荐答案
来自 https://wiki.python.org/moin/元组语法
单元素元组
单元素元组看起来像:
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.
这篇关于(1,) 在 Python 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文