Fetch the repository succeeded.
#列表,在python中没有数组的概念只有列表和元组,类似其他编程语言的数组,通过[]来定义列表
#一组有序项目的集合,可变的数据类型(可进行增删改查)
#列表是以方括号”[]“包围的数据集合,不同成员之间以”,“分割
#列表中可以包含任何数据类型,也可以包含另一个列表
#列表可通过序号访问其中成员
#常用的列表操作:
#list.append(x) 追加成员x,到列表最后一个位置
#list.pop(i) 删除成员,删除第i个成员
#list.count(x) 计算列表中参数是x的个数
#list.remove(x) 删除列表中的成员,直接删除成员x
#list.extend(L) 向列表中追加另一个类表L
#list.reverse() 将列表中的顺序颠倒,即从后向前排序
#list.index(x) 获得参数x在列表中的位置
#list.sort() 将列表中的成员排序
#list.insert(index,x) 向列表中第index位置插入数据x
a = ["php","javascript","java","android","oc"]
print("---------------输出下标2的值---------------")
print(a[2])#获取下标为2的值,既为java,下标从0开始
print("---------------修改列表的值---------------")
a[2] = "java是面向对象编程语言"#修改下标为2的值
print(a[2])
print("-----------——---计算列表个数----------------")
print(len(a))#通过len计算a列表的个数
print("-------------—--遍历列表-----------------")
for i in range(0,len(a)):
print(a[i])
print("-------------—--字符串序列化成列表-----------------")
s = "我是sunny"
s1 = list(s)
print(s1)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。