【发布时间】:2021-11-13 16:16:36
【问题描述】:
我正在使用 vscode。
我想在 vscode 中运行 python 时从 input.txt 中获取输入。
所以我像下面这样设置了 launch.json。 (添加“参数”)
{
"version": "0.2.0",
"configurations": [
{
"args": [
"<",
"input.txt"
],
"name": "Python: Curre545435nt File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
}
]
}
(参考:https://code.visualstudio.com/docs/editor/debugging#_redirect-inputoutput-tofrom-the-debug-target)
现在当我运行 python 时,vscode 会发送如下命令。
c:; cd 'c:\Users\user\Desktop\ct'; &
'C:\Users\user\miniconda3\python.exe'
'c:\Users\user\.vscode\extensions\ms-python.python-2021.9.1230869389\pythonFiles\lib\python\debugpy\launcher'
'13094 ' '--' 'c:\Users\user\Desktop\workingfolder\.vscode\launch.json'
'<' 'C:\Users\user\Desktop\workingfolder\input.txt'
这里的问题是 '')
由于直接在终端测试,确认应该修改如下图才能正常运行。
'python.exe' '<' 'input.txt' (not correct)
'python.exe' < 'input.txt' (correct)
我需要在 vscode 中设置哪些设置才能正常工作?
【问题讨论】:
标签: python redirect visual-studio-code input