开始学习PIL,写了段生成简单图片的代码。
from PIL import Image,ImageDrawimg = Image.new('RGB', (300, 200), (61, 61, 61))ImageDraw.Draw(img, 'RGB')with open('1.png', 'wb')as f:img.save(f, format = 'png')img.show() # 使用默认图片查看器打开
结果刚运行就报错DLL load failed…
分析应该是没安装完整的问题,下面是解决办法。
1.使用pip uninstall pillow, 卸掉当前安装的pillow,博主因为是python2和3共用,所以前面有python3 -m
2.pip install pillow重新安装pillow
3.再次运行,问题解决
博主其他系列文章:
[1] 【python实用特性】-切片
[2] 【python实用特性】- 迭代、可迭代对象、迭代器
[3] 【python实用特性】- 列表生成式
[4] 【python实用特性】- yield生成器
[5] 【Matplotlib】-自定义坐标轴刻度完成20万+数据的可视化
[6] Python+selenium实现自动爬取实例
[7] Python爬取豆瓣Top250-改进版
[8] requests 设置请求头、代理