问题:使用with方法在pycharm中写图片和视频文件时,无法正确将图片写入项目中。
# with方法读图片文件
with open(r'img.png', 'rb') as file:
print(file.read())
# with 方法写图片文件
with open(r'img.png1', 'wb') as file:
result = file.write()
# with方法读图片文件
with open(r'img.png', 'rb') as file:
print(file.read())
# with 方法写图片文件
with open(r'img.png1', 'wb') as file:
result = file.write()
"""
copy()方法
"""
from PIL import Image
picture = Image.open('yase.jpeg')
copy_pic = picture.copy() # 复制
copy_pic.save('copy_pic.jpg')