在元组定义中有后缀逗号的语法规则是什么?对于单个元素元组,需要后缀逗号。a = ('foo',)多个元素的元组怎么样?不管后缀逗号是否存在,它们似乎都是有效的。这是对的吗?在我看来,使用后缀逗号更容易编辑。这是一种糟糕的编码方式吗?a = ('foo1', 'foo2')b = ('foo1', 'foo2',)
3 回答

拉丁的传说
TA贡献1789条经验 获得超8个赞
a = [ "a", "b" "c"]

MMMHUHU
TA贡献1834条经验 获得超8个赞
(1) # the number 1 (the parentheses are wrapping the expression `1`)(1,) # a 1-tuple holding a number 1
someBigTuple = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, #... 10000000000, )

Smart猫小萌
TA贡献1911条经验 获得超7个赞
a = [ 1, 2, 3]
a = [ 1, 2, 3, 4]
a = [ 1, 2,- 3+ 3,+ 4 ]
a = [ 1, 2, 3,]
a = [ 1, 2, 3,+ 4, ]
添加回答
举报
0/150
提交
取消