1、Python的with…as的用法
原先写法:
1.file = open("/tmp/foo.txt")
2.try:
3. data = file.read()
4.finally:
5. file.close()
使用with … as …替换
1.with open("/tmp/foo.txt") as file:
2. data = file.read()
2、Image模块的convert()函数,用于不同模式图像之间的转换
PIL中有九种不同模式。分别为1,L,P,RGB,RGBA,CMYK,YCbCr,I,F。