def to_str(ss): if type(ss) in (int,str,unicode): value_str.append(ss) elif type(ss) is dict: for i in ss: to_str(ss[i]) elif type(ss) is list: for i in ss: to_str(i)global value_strvalue_str=[]a=[1,[2],3,[4,[5,{6:9}]]]to_str(a)print value_str>>[1, 2, 3, 4, 5, 9]