0.目录 1.参考2.没事画个流程图3.完整代码4.改进方向 1.参考 https://en.wikipedia.org/wiki/Cosine_similarity https://zh.wikipedia.org/wiki/%E4%BD%99%E5%BC%A6%E7%9B%B8%E4%BC%BC%E6%80%A7 Cosine similarityGiven two vectors of attributes, A and B, the cosine similarity, cos(θ),…
在工作中经常遇到一些验证码,这些是怎么生成的呢,今天我用Python编写了下 import randomcode = []for i in range(6): if i == random.randint(1,5): code.append(str(random.randint(1,4))) else: tmp = random.randint(65,90) code.append(chr(tmp))print ''.join(code)…
# 生成一个六位随机验证码 import random # random 生成随机数 temp = '' for i in range(6): num = random.randrange(0,6) if num == 3 or num == 1: #如果循环到3 或 1 生成随机数字0~9 rad2 = random.randrange(0,10) temp = temp+str(rad2) else: #否则 随机生成字母 rad1 = random.randrange(65,91) #大于…