WechatIMG16.jpeg
仓库地址
python-captcha
🐰持续更新 ing~ 欢迎 star / fork
环境
Python 3.5.2
Pillow 7.2.0
Pillow 是一个 Python 图像处理库。
安装Pillow
安装
pip3 install pillow
查看版本
$ python3 -m pip freeze | grep Pillow
Pillow==7.2.0
代码
# -*- coding:utf8 -*-
from PIL import Image
import hashlib
import time
import os
import math
import string
class VectorCompare:
'''
向量空间类
'''
def magnitude(self, concordance):
'''
计算矢量大小
'''
total = 0
for word, count in concordance.items():
total += count ** 2 # 返回count的2次幂
return math.sqrt(total)
def relation(self, con