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