本文主要是介绍Python3,函数命名以及递归,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
movies = ["The Holy Grail",1975,"Terry Jones & Terry Gilliam",91,
["Graham Chapman",
["Micheal Palin","John Cleese","Terry Gilliam","Eric Idle","Terry Jones"]]]
#直接输出
#for each in movies:
# print(each)
"""The Holy Grail
1975
Terry Jones & Terry Gilliam
91
['Graham Chapman', ['Micheal Palin', 'John Cleese', 'Terry Gilliam', 'Eric Idle', 'Terry Jones']]
处理嵌套列表
for each_movie in movies:
if isinstance(each_movie,list):
for each_temp in each_movie:
print(each_temp)
else:
print(each_movie)"""
def print_lol(the_list):
for each_item in the_list:
if isinstance(each_item,list):
print_lol(each_item)
else:
print(each_item)
print_lol(movies)
这篇关于Python3,函数命名以及递归的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!