What is the syntax rule for having trailing commas in tuple definitions?

前端 未结 10 1566
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 05:54

In the case of a single element tuple, the trailing comma is required.

a = (\'foo\',)

What about a tuple with multiple elements? It seems t

10条回答
  •  野性不改
    2020-11-22 06:21

    It's optional: see the Python wiki.

    Summary: single-element tuples need a trailing comma, but it's optional for multiple-element tuples.

提交回复
热议问题