我正在尝试使用python显示图像。我使用了以下代码:
from PIL import Image
img = Image.open("pic.jpg")
img.show()
del img我检查了一切是否都已安装,并在Image.open部件中尝试了不同的选项,但都不起作用。我甚至没有错误(所以其他主题在我的例子中是无关紧要的)。
我是python新手,所以我不知道如何调试它。我的代码只是执行,但什么也没发生。
如果你有主意,我可以试试。谢谢。
发布于 2021-03-10 19:49:23
通过将代码更改为以下代码,您可以获得一些用于调试Python的信息:
from PIL import Image
import subprocess
import sys
# Print the full path of the Python interpreter you are using
print(sys.executable)
# Print the working directory that your program is running in
subprocess.run('pwd')
# Print directory listing
# WINDOWS VERSION: subprocess.run('DIR')
subprocess.run(['ls', '-l'])
# Open the image
img = Image.open("pic.jpg")
# Check image loaded and its size and type
print(img)
# Display image
img.show()
# Check program ran to completion
print('Done')https://stackoverflow.com/questions/66053088
复制相似问题