列表
print()
append()增加一个到末尾
pop()删除最后一个
len()
extend(["",""])增加数据项集合
insert(x,"")在某个位置之前增加一个
print(movies[4][1][3])支持列表嵌套
两种循环
for count in movies:
print(count)
----
count = 0
while count < = len(movies)
print(movies[count])
count +=1
(python ''和""没有区别)
BIF内置函数
isinstance(name, list)检查类型,输出True/False BIF
dir(__builtins__)查看BIF
help()查看帮助
if isinstance(name, list):
***
else:
***
函数、库
def 函数名(参数):
代码组
反复重用的代码需要定义函数
pypi 第三方库
""" """python注释
#注释一行
一个小例子
#names = ['J','E',['C','I'],'M',['P',['F','K']]]
#list.print_movie(names,True)
python2.7
def print_movie(movie_list,indent=False,level=0):
for each_movie in movie_list:
if isinstance(each_movie,list):
print_movie(each_movie,indent,level+1)
else:
if indent:
for tab_stop in range(level):
print("\t"),
print(each_movie)
else:
print(each_movie)
python3
def print_lol(the_list,indent=False,level=0):
for each_item in the_list:
if isinstance(each_item,list):
print_lol(each_item,indent,level+1)
else:
if indent:
for tab_stop in range(level):
print("\t",end='') #python3用法,打印不换行
print(each_item)