Python基础之PIL(pillow)模块实例
pillow模块内容繁杂,因此使用实例展示内容
##1. 安装PIL(windows)
方式一:打开cmd(管理员模式) — 输入“pip install pillow” — 自动下载安装 ---- 出现 “Successfully installed pillow-5.2.0”即安装成功
使用pip list可查看是否安装pillow
C:\Windows\system32>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
asn1crypto (0.24.0)
cffi (1.11.5)
cryptography (2.2.2)
idna (2.7)
Pillow (5.2.0)
pip (9.0.1)
pycparser (2.18)
pygame (1.9.3)
PyMySQL (0.9.2)
setuptools (28.8.0)
six (1.11.0)
##2. 验证码生成实例
from PIL import Image, ImageDraw, ImageFont
import random
# 添加字母
def creatImg(width,height):
# 偏移量x
global x
# 创建新的画布,透明度为完全透明
img = Image.new("RGBA", (width, height), (0, 0, 0, 0

本文介绍了Python中的PIL(Pillow)模块,通过实例展示了如何在Windows上安装PIL,以及如何运用PIL实现验证码生成和简单的图片鉴黄功能。注意,该鉴黄实例可能存在误判,如将自拍照片判断为黄图。
最低0.47元/天 解锁文章
446

被折叠的 条评论
为什么被折叠?



