码迷,mamicode.com
首页 > 其他好文 > 详细

列表学习笔记1⃣

时间:2017-11-14 11:29:27      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:python 列表与函数学习

#使用函数调用;


#函数迭代:

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 列表与函数学习

原文地址:http://357712148.blog.51cto.com/6440370/1981477

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!