无法使用 VS Code 在 python 中打开文件
问题描述:
当我在 VS Code 中运行 python 脚本时,我似乎无法打开基本文本文件,当我在 Idle 中使用它时代码运行良好,但 VSCode 会给我一个 FileNotFound 错误,是否有某种扩展允许我要这样做吗?现在我只使用 Python 和 Code Runner 扩展.我的代码示例:
I can't seem to open basic text files when I run a python script in VS Code, the code runs fine when I use it in Idle but VSCode will give me a FileNotFound error, is there some sort of extension that allows me to do this? Right now I'm only using the Python and Code Runner extension. example of my code:
def getInput(textFile):
file=open(textFile,'r')
print(file.readlines())
答
尝试设置
"python.terminal.executeInFileDir": true,
"python.terminal.executeInFileDir": true,
在您的 VSCode 设置中
in your VSCode Settings