python - 如何使用 VSCode 和管道命令进行调试
问题描述
我正在使用 VScode,我想调试一个与管道命令一起使用的程序。
在控制台中,我运行我的程序
cat dataset.txt | python my_program.py
如何配置 VSCode 以传递cat
命令,以便正确调试程序?
我怀疑我需要编辑launch.json
?
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
解决方案
如果将“console”更改为“externalTerminal”,则在运行程序时将打开一个外部终端窗口。此窗口已将标准输入连接到键盘,因此如果您键入或粘贴内容,它将被传递给程序,直到您发送或键入 ctrl-z。标准输出转到窗口。调试和断点按预期工作。
推荐阅读
- c# - 如何在 c#.Net 中使用 .pem 文件生成带有时间戳的客户端密钥
- javascript - 如何使用 javascript/jQuery 在 HTML 内容中搜索/匹配 regx?
- performance - Css 过渡所有 Vs 特定过渡
- laravel - 在不同(丢弃的)分支中创建的迁移显示在 master 中
- c# - 使用 excel 插件登录到 web 应用程序后,连续的 excel 工作簿也会在登录时打开
- python-3.x - Matplotlib 通过鼠标事件使图像可拉伸
- php - 不同格式的PHP Datetime检查日期
- javascript - SoundManager.setup 未在 IOS 上运行
- node.js - MEAN Stack:未提供代币
- php - Vue 资源空数据