遍历一个不定长列表,最后一个元素特殊处理

1590阅读 0评论2016-11-10 Dahuanxihuopusa
分类:LINUX

'''
Readme:
This script shows the algrothm that list all element but process the last
one specially, while do not know which one is the last one
Need two pointers:
      one for current element and the other one for the next element
'''
current = next = read (directory)
while (next = read() != NULL):
    print current + ', which is not the last one'
    current = next


#after the while, current point to the last one
print current + ', is the last one'

上一篇:emacs 配色丢失找回来
下一篇:没有了