python 模拟 java hashcode

def hashCode(value):
    h=0
    if h == 0 or len(value) > 0:  
        for i in range(0,len(value)):
            h = 31*h + int(value[i]);
    return h

 

posted @ 2015-12-15 17:31  martinsun  阅读(1886)  评论(0编辑  收藏  举报