首页 > 解决方案 > 在 IDLE 上导入文件(python 代码编辑器)

问题描述

这似乎是一个愚蠢的问题,但我确实遇到了很多麻烦:我需要能够将文件(如图像)导入 IDLE,以便在程序运行时打开它。我是否遗漏了一些非常明显的东西,或者这在 IDLE 上是不可能的?谢谢。顺便说一句,我在 Python 中使用 Chromebook。

标签: python

解决方案


from PIL import Image
with Image.open(image_directory) as image:
    pass

From there you can use PIL's various functions to edit the image. Don't forget to save it, though.


推荐阅读