文件的内存读取 ,以及image图片(二进制)的读取

1 #在python2.x中导入模块方法:
2 from StringIO import String
3 #在python2.x中它还有个孪生兄弟,运行速度比它快,用c实现的
4 from cStringIO import StringIO
5 #在python3.x中,StringIO已经在io模块中了,导入方法
6 from io import StringIO,BytesIO (根据写的字符格式导入相应的模块)
 1 关于Pillow与PIL
 2 
 3 PIL(Python Imaging Library)是Python一个强大方便的图像处理库,名气也比较大。不过只支持到Python 2.7 4 
 5 PIL官方网站:http://www.pythonware.com/products/pil/
 6 
 7 Pillow是PIL的一个派生分支,但如今已经发展成为比PIL本身更具活力的图像处理库。目前最新版本是3.0.0 8 
 9 Pillow的Github主页:https://github.com/python-pillow/Pillow
10 Pillow的文档(对应版本v3.0.0):https://pillow.readthedocs.org/en/latest/handbook/index.html
11 Pillow的文档中文翻译(对应版本v2.4.0):http://pillow-cn.readthedocs.org/en/latest/
12 
13 Python 3.x 安装Pillow
14 
15 给Python安装Pillow非常简单,使用pip或easy_install只要一行代码即可。
16 
17 在命令行使用PIP安装:
18 pip install Pillow
19 
20 或在命令行使用easy_install安装:
21 easy_install Pillow
22 
23 安装完成后,使用from PIL import Image就引用使用库了。比如:
24 from PIL import Image
25 im = Image.open("bride.jpg")
26 im.rotate(45).show()  #rotate()是旋转角度,可以不写,默认是0  即im.show()
***补充 pycharm 可能由于pip版本或者没有mai文件装不了,直接cmd 进入python3的安装目录,直接pip install pillow

猜你喜欢

转载自www.cnblogs.com/qlshao/p/8939829.html