如何使用&quot" quot;在VS代码中以在当前文件夹之外加速文件夹
我一直在尝试访问当前文件夹之外的文件夹,但是当我使用“ ../images/image.png”时,它会出现一个文件错误错误。现在,在空闲中运行此代码没有任何错误,并且可以完美工作。如何在VS代码中使用../?
使用pygame.display.set_icon(pygame.image.load(f“ ./ images/uii/ui/logo.png”)))
给出: - filenotfounderror:no suke file core。 /code>在闲置3.9中运行它,没有给我任何错误
I've been trying to access a folder outside my current folder, however when I Use "../images/image.png" it gives a FileNotFound error. Now running this code in IDLE gives no error and works perfectly. How can i use ../ in Vs code?
Using pygame.display.set_icon(pygame.image.load(f"./images/ui/logo.png"))
which gives :- FileNotFoundError: No such file or directory.
running it in IDLE 3.9, doesnt give me any error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先要理解的是,如果VSCODE中的代码涉及路径,则基于工作区的根目录将所有内容都检索。即使您使用”。在工作空间下的一个深目录中,这仍然代表工作区目录,而不是当前目录。
因此,我们需要做的是改变我们的思维,并将您想要的文件作为根目录导入您想要的文件。
这也意味着“ ..”不会出现在VSCODE中。因为我们需要的所有文件都在工作空间中,所以我们不会在工作区外使用父目录。
例如,
如果您将其放置为这样,则可以根据当前文件检索工作空间中的文件,而无需复杂的定位。
您可以参考此 evary 。它有类似的问题。
The first thing to understand is that if the code in vscode involves paths, everything is retrieved for the root directory based on the workspace. Even if you use "." in a deep directory under the workspace, this still represents the workspace directory, instead of the current directory.
So what we need to do is to change our thinking and import the files you want with the workspace as the root directory.
This also means that ".." will not appear in vscode. Because all the files we need are in the workspace, we will not use the parent directory outside the workspace.
For example,
If you place it like this, you can retrieve the file anywhere in the workspace without complex positioning based on the current file.
You can refer to this issue. It has similar problems with you.
我假设两个文件夹都在同一目录中。这意味着您应该使用“ ./”而不是“ ../”::)
I am assuming that both folders are in the same directory. This means that you should use “./“ instead of “../“ :)