标签:python class move 数据 -- style color bsp rem
列表的操作
1.列表的修改
>>> name [‘Frank‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]] >>> name[0] = "Frank Bian" >>> name [‘Frank Bian‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]]
2.列表的插入
>>> name [‘Frank Bian‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]] >>> name.insert(1,"Marlon") #插入到位置就是其下标的值 >>> name [‘Frank Bian‘, ‘Marlon‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]]
3 列表的追加(append object to end)
>>> name [‘Frank Bian‘, ‘Marlon‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]] >>> help(name.append) >>> help(name.append) >>> name.append(‘Duff‘) >>> name [‘Frank Bian‘, ‘Marlon‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘], ‘Duff‘]
4 列表元素删除(L.remove(value) -> None -- remove first occurrence of value.
Raises ValueError if the value is not present.)
>>> name.append(‘Duff‘) >>> name [‘Frank Bian‘, ‘Marlon‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘], ‘Duff‘, ‘Duff‘] >>> name.remove(‘Duff‘) >>> name [‘Frank Bian‘, ‘Marlon‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘], ‘Duff‘]
标签:python class move 数据 -- style color bsp rem
原文地址:http://www.cnblogs.com/frankb/p/6104337.html