PIL.Image.open() 仅提供文件名时搜索图像的位置在哪里?

huangapple go评论63阅读模式
英文:

Where does PIL.Image.open() search for image when only the filename is given?

问题

我需要制作一个人们可以在Python上下载的象棋游戏的变种,但现在我需要图像。
(还有一件非常令人惊讶的事情是,文件资源管理器中显示的目录有时与PyCharm中的目录不同)

我尝试将它们放在venv旁边,但没有成功。我还尝试将它们放在Scripts中,但也没有成功。

英文:

I need to make a variation of chess game where people can download it on python but i need images now.
(Also something very surprising is that the directory shown in File Explorer is sometimes different than the directory in pycharm)

I tried putting them beside venv but it didn't work. I also tried in Scripts but i didn't work either.

答案1

得分: 0

它查看当前目录。您可以通过运行以下代码来查看当前目录:

import os
print(f'当前目录:{os.getcwd()}')
英文:

It looks in the current directory. You can see where that is by running this:

import os
print(f'Current directory: {os.getcwd()}')

huangapple
  • 本文由 发表于 2023年2月18日 22:12:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75493904.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定