列表学习笔记1⃣

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了列表学习笔记1⃣相关的知识,希望对你有一定的参考价值。

#使用函数调用;


#函数迭代:

def print_list(the_list):

for each_item in the_list:

if isinstance(each_item,list): #判断是否是链表

print_list(each_item)    #如果不是调用自己

else:

print each_item       #如果是直接输出


#第一次调用不用函数

def nubmer():

movice = ["The Holy Grail",1975,"Terry Jones & Terry Gilliam",91,["Graham Chapman",["Michael Palin","John Cheese","Theeey Gilliam","Eric Idle","Terry Jones"]]]

print(movice[4][1][3])

print"------------------"

print(movice[1])

print"==================="

print(movice[4][1])

print"-------------------"

print(movice)

print(‘===============‘)

for i in movice:

if isinstance(i,list):

for y in i:

if isinstance(y,list):

for k in y:

print k

else:

   print y

else:

print i

print("======================")

#调用函数输出

print_list(movice)

print nubmer()


=============

Eric Idle

------------------

1975

===================

[‘Michael Palin‘, ‘John Cheese‘, ‘Theeey Gilliam‘, ‘Eric Idle‘, ‘Terry Jones‘]

-------------------

[‘The Holy Grail‘, 1975, ‘Terry Jones & Terry Gilliam‘, 91, [‘Graham Chapman‘, [‘Michael Palin‘, ‘John Cheese‘, ‘Theeey Gilliam‘, ‘Eric Idle‘, ‘Terry Jones‘]]]

===============

The Holy Grail

1975

Terry Jones & Terry Gilliam

91

Graham Chapman

Michael Palin

John Cheese

Theeey Gilliam

Eric Idle

Terry Jones

======================

The Holy Grail

1975

Terry Jones & Terry Gilliam

91

Graham Chapman

Michael Palin

John Cheese

Theeey Gilliam

Eric Idle

Terry Jones

None



本文出自 “知止内明” 博客,请务必保留此出处http://357712148.blog.51cto.com/6440370/1981477

以上是关于列表学习笔记1⃣的主要内容,如果未能解决你的问题,请参考以下文章

python学习笔记列表操作

Python学习笔记-列表

Python学习笔记__3.3章 列表生成式

python学习笔记之列表

Python学习笔记#列表操作常用的函数

python学习笔记列表和元组