Python基础之PIL(pillow)模块实例

本文介绍了Python中的PIL(Pillow)模块,通过实例展示了如何在Windows上安装PIL,以及如何运用PIL实现验证码生成和简单的图片鉴黄功能。注意,该鉴黄实例可能存在误判,如将自拍照片判断为黄图。
摘要由CSDN通过智能技术生成

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
    # 创建新的画布,
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值