gpt4 book ai didi

python - 使用 VS Code 在 python 中打开文件时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-04 09:47:42 26 4
gpt4 key购买 nike

当我在 VS Code 中运行 python 脚本时,我似乎无法打开基本文本文件,当我在 Idle 中使用它时代码运行良好,但 VSCode 会给我一个 FileNotFound 错误,是否有某种扩展允许我要这样做吗?现在我只使用 Python 和 Code Runner 扩展。我的代码示例:

def getInput(textFile):
file=open(textFile,'r')
print(file.readlines())

最佳答案

尝试设置

"python.terminal.executeInFileDir": true,

在您的 VSCode 设置中

关于python - 使用 VS Code 在 python 中打开文件时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49143852/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com