1 Star 0 Fork 0

闲云野鹤/python

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
列表.py 1.52 KB
Copy Edit Raw Blame History
闲云野鹤 authored 2015-07-16 12:56 . add 02.md和一些python语法
#列表,在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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xianyunyehe/python.git
git@gitee.com:xianyunyehe/python.git
xianyunyehe
python
python
master

Search

D67c1975 1850385 1daf7b77 1850385