list=['a','b','c','d','e','f','g']while list: print ' '.join(list[:4]) list = list[5:] # 输出 # a b c d# f g
自己写一个比较函数,然后list.sort(cmp=func)