>>> def my_print(s):
....... if type(s) == str:
... ..........print s
... .....else:
... ..........for i in s:
... ..........。。。my_print(i)
...
>>> d = ['li', ['mark', 'jim', 'lily', ['lucy', 'gao']]]
>>> my_print(d)
li
mark
jim
lily
lucy
gao
>>>
自定义函数递归吧:
def myprint(a):
____for i in a:
________if isinstance(i,list):
____________myprint(i)
________else:
____________print i
a = ["li",["mark","jim","lily",["lucy","gao"]],"master"]
myprint(a)
>>>
li
mark
jim
lily
lucy
gao
master