1. list操作

A.添加元素

 1 list = ["C++","C", "Java", "Python"]
 2 """
 3  list中元素的添加,方括号中必须带有冒号
 4  添加的元素值,如果不带有方括号则拆分成一个个字符作为元素进行添加
 5 """
 6 # 1
 7 list[list.__len__():] = ["C#"]
 8 print(list)
 9 
10 # 2
11 list[len(list):] = ["Per"]
12 print(list)
13 
14 # 3
15 list[len(list):] = "shell"
16 print(list)
View Code

结果:

 

posted on 2018-04-12 12:42  人生一世,草木一秋。  阅读(158)  评论(0编辑  收藏  举报