📌  相关文章
📜  PIL\Image.py",第 2975 行,打开 fp = builtins.open(filename, "rb") PermissionError: [Errno 13] Permission denied: - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:30.218000             🧑  作者: Mango

代码示例1
import os, sys
from stat import*

import matplotlib
import matplotlib.pyplot as plt
import PIL
import matplotlib.image as mpimg

rows = 2
os.chmod(r'C:\Users\Murat\PycharmProjects\pythonProject\Chess Game\Chess_pieces_images', 0o777)
os.chdir(r'C:\Users\Murat\PycharmProjects\pythonProject\Chess Game\Chess_pieces_images') #path to images
piece_images = os.listdir(r'C:\Users\Murat\PycharmProjects\pythonProject\Chess Game\Chess_pieces_images')


for num, x in enumerate(piece_images):
    img = PIL.Image.open(x)
    plt.subplot(rows, 8, num + 1) #nrows, ncols, index,**kwargs
    plt.title(x.split('.')[0])
    plt.axis('off')
    plt.imshow(img)```