#使用函数调用;
#函数迭代:
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
原文地址:http://357712148.blog.51cto.com/6440370/1981477