首页 > 代码库 > python Day04

python Day04

python list

 

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author Jean

# list

# append

names = []

names.append("tom")

names.append("jean")

names.append("robin")
print(names)

# 修改
names[1] = "joker"
print(names)
# remove
names.remove("tom")
print(names)

#select
print(names.index("robin"))

#count

print(names.count("robin"))

#reverse

names.reverse()
print(names)

#sort 按照ascll码排序

names.sort()
print(names)
#extend

names2 = [1,2,3,4]

names.extend(names2)
print(names)

python Day04