About 55 results
Open links in new tab
  1. Python typing: tuple [str] vs tuple [str, ...] - Stack Overflow

    Apr 25, 2022 · 22 giving a tuple type with ellipsis means that number of elements in this tuple is not known, but type is known: ... not using ellipsis means a tuple with specific number of elements, e.g.: …

  2. 如何理解和使用tuple? - 知乎

    tuple一般在中文中称为元组,或者说n元组。就是由n个元素组成的一种有序数据结构(当然n是不小于零的整数)。不同的编程语言对元组有不同实现,但既然标签打的Python,那就只谈和Python中的元 …

  3. python - What is a tuple useful for? - Stack Overflow

    Sep 9, 2014 · 1 A tuple is useful for storing multiple values.. As you note a tuple is just like a list that is immutable - e.g. once created you cannot add/remove/swap elements. One benefit of being …

  4. c++11的 元组(tuple)有什么用?有什么使用场景? - 知乎

    当模板函数需要超过 1 个变长参数时,使用 tuple 有奇效。 例子 1 piecewise_construct class 里存在多个成员,这些成员的构造各自均需要多个参数。

  5. IndexError: tuple index out of range ----- Python - Stack Overflow

    Nov 30, 2013 · A tuple consists of a number of values separated by commas. like ... tuple are index based (and also immutable) in Python. Here in this case have only two index 0, 1 available but you …

  6. python中的tuple应该怎么读? - 知乎

    python中的tuple应该怎么读? 有道词典是这样说的: 英 ['tjuːp (ə)l] 美 ['tjup (ə)l] 百度是这样说的: [英]tʌpl [美]tʌpl 书上是这样说的: 发音… 显示全部 关注者 26

  7. python - List vs tuple, when to use each? - Stack Overflow

    Using a tuple instead of a list is like having an implied assert statement that this data is constant, and that special thought (and a specific function) is required to override that. Some tuples can be used as …

  8. python 的 tuple 是不是冗余设计? - 知乎

    从这个意义上看,tuple并不冗余。 也许Python中的tuple为数不多值得吐槽的点之一就在于这东西在语法上有点歧义,因为解释器不能很容易地分辨一个圆括号到底代表着一个tuple的起始还是仅仅用来提 …

  9. Convert list to tuple in Python - Stack Overflow

    Have you assigned the name 'tuple' as a variable name? it should work fine. L is a list and we want to convert it to a tuple. L = [1, 2, 3] tuple (L) By invoking tuple, you convert the list (L) into a tuple. As …

  10. types - What are "named tuples" in Python? - Stack Overflow

    Jun 4, 2010 · Named tuples are basically easy-to-create, lightweight object types. Named tuple instances can be referenced using object-like variable dereferencing or the standard tuple syntax. …