我试图从元素周期表的大图像中裁剪出特定的元素,然后将它们保存在一个特定的文件目录中,这个文件目录在一个额外的文件夹中,这个文件夹和我要使用的程序在同一个文件目录中。在
我看了另一个关于堆栈溢出的回答问题,它与我的问题有相似之处:
How can I save an image with PIL?
,但此用户使用了“numpy”。我以前在学校只学过python基础知识,现在我利用空闲时间学习了'tkinter'和现在的'pill'(pill),我对python的这些模块还很陌生,很难掌握这两个模块令人困惑的文档,我也不知道什么是“numpy”或如何使用它。在
这是我要运行的代码:#Saving G1 elements as their own image
from PIL import Image
Periodic_Table = Image.open("Periodic Table Bitmap.bmp")
G1_List = ["Hydrogen.bmp","Lithium.bmp","Sodium.bmp",
"Potassium.bmp","Rubidium.bmp","Caesium.bmp","Francium.bmp"]
starting_coords = (180,86,340,271)
for i in range(7):
y1 = 86 + (i * 187)
y2 = 86 + ((i+1)* 187) - 3
cropped_region = (180,y1,340,