python generator

def reverse(data):
    for index in range(len(data)-1, -1, -1):
        yield data[index]
for char in reverse('golf'):
  print char

 

 

posted @ 2018-09-26 17:43  友哥  阅读(133)  评论(0编辑  收藏  举报