1.二元运算符和比较运算
a_list=['foo',2,[4,5]]
a_list[2]=[3,4] #将a_list 第三位改成[3,4]
a_list`
其中有一些对象不可变 如字符串和元祖 会出现报错
a_tuple=(3,5,(4,5))
a_tuple[1]='four'
TypeError Traceback (most recent call last)
<ipython-input-9-29e698109a5a> in <module>
1 a_tuple=(3,5,(4,5))
----> 2 a_tuple[1]='four'
2. 数值类型
python基本的类型就是int 和float
python 的字符串是不可变的 无法修改一个字符串
ical=54654654
a= 'this is a string'
a[10]='f'
TypeError Traceback (most recent call last)
<ipython-input-14-408c566290d8> in <module>
1 ical=54654654
2 a= 'this is a string'
----> 3 a[10]='f'
TypeError: 'str' object does not support it