One - One Code All

Blog Content

python返回第一个最小的大于0的数

Python 算法   2011-06-02 21:00:20
def min_no_zero(list1):
    d = {}
    min_flag = 0
    for i, v in enumerate(list1):
        d[v] = i
    list1.sort()
    for i in list1:
        if i > 0:
            min_flag = i
            break
    return d[min_flag]



上一篇:python中返回列表中的第二小的元素的下标
下一篇:Nelder–Mead method

The minute you think of giving up, think of the reason why you held on so long.