一些最简单的代码:
cast = ["a",1,["b",2],"c",["d","e","f","g"]]
#i=0
print cast
for i in cast:
if isinstance(i,list):#attention on the first data ,it's a suffix nor a list
print "it's a list!"
else:
print(i)#the same as the last comment
print "I love Python"
本文通过一个简单的Python代码示例展示了如何使用列表和嵌套数据结构,并介绍了基本的遍历方法及条件判断技巧。通过对列表中不同类型的元素进行判断和打印,帮助读者理解Python的数据结构操作。
1万+

被折叠的 条评论
为什么被折叠?



