我在visual studio中打开了一个python项目文件夹并运行getter.py
,其中包含以下代码:
getter.py
with open('instruments.txt', 'r') as f:
instrument_list = f.read().splitlines()
我的文件夹树如下:
proj
-downloaders
--getter.py
instruments.txt
signals.py
如您所见,getter.py
位于donwloaders
文件夹中。为什么visual studio在没有FileNotFoundError
的情况下运行上面的脚本?请注意,当我将instructions.txt
移动到downloaders
文件夹时,它会抛出FileNotFoundError
。我应该更改设置中的内容吗?
确保将txt文件放在python脚本目录中,而不是python项目目录中。
proj
-downloaders
--getter.py
--instruments.txt
signals.py