python中怎么识别验证码
更新:HHH   时间:2023-1-7


这期内容当中小编将会给大家带来有关python中怎么识别验证码,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

python有哪些常用库

python常用的库:1.requesuts;2.scrapy;3.pillow;4.twisted;5.numpy;6.matplotlib;7.pygama;8.ipyhton等。

具体如下。

import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from PIL import Image

#打开图像
im=np.array(Image.open('yzm.png'))

#得到图像3个维度
h,w,san=im.shape

X=[(h-x,y) for x in range(h) for y in range (w) if im[x][y][2]<200]

#将X转换成numpy的array类型,方便后续运算操作
X=np.array(X)

n_clusters=4
k_means=KMeans(init='k-means++',n_clusters=n_clusters)
k_means.fit(X)

k_means_labels=k_means.labels_
k_means_cluster_centers=k_means.cluster_centers_
k_means_labels_unique=np.unique(k_means_labels)

colors=['#4EACC5','#FF9C34','#4E9A06','#FF3300']
plt.figure()
plt.hold(True)
for k,col in zip(range(n_clusters),colors):
 my_members=k_means_labels==k
 cluster_center=k_means_cluster_centers[k]
 plt.plot(X[my_members,1],X[my_members,0],'w',markerfacecolor=col,marker='.')
 plt.plot(cluster_center[1],cluster_center[0],'o',markerfacecolor=col,markeredgecolor='k',markersize=6)

plt.title('KMeans')
plt.grid(True)
plt.show()

上述就是小编为大家分享的python中怎么识别验证码了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注天达云行业资讯频道。

返回开发技术教程...