>> aa[0](12,34)>>> aa[0]=(1,2)Traceback (most recent call last): file "",line 1,in TypeError: 'tuple' object does not support item assignment>>> aa[0][0]12>>> aa[0][0]=34Traceback (most recent call last): file "",in TypeError: 'tuple' object does not support item assignment
>> pos = {0: (20,20),1: (20,40),2: (40,3: (40,4: (30,30)}>>> pos{0: (20,30)}>>> pos[0]=(1,2)>>> pos{0: (1,2),30)}>>>
>> a = dict(one=1,two=2,three=3)>>> b = {'one': 1,'two': 2,'three': 3}>>> c = dict(zip(['one','two','three'],[1,2,3]))>>> d = dict([('two',('one',1),('three',3)])>>> e = dict({'three': 3,'one': 1,'two': 2})>>> a == b == c == d == eTrue
>>a=("one","two")>>>a[0]'one'>>>b=("one")>>>b[0]'o'>>>c=("one",)c[0]
'one'
d="one",>>>d[0]
one
总结 以上是内存溢出为你收集整理的python:元组和小括号的误导全部内容,希望文章能够帮你解决python:元组和小括号的误导所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)