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

慕标琳琳
TA贡献1830条经验 获得超9个赞
a = [ "a", "b" "c"]

扬帆大鱼
TA贡献1799条经验 获得超9个赞
(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, )

倚天杖
TA贡献1828条经验 获得超3个赞
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
提交
取消