python - VsCode 在运行模式和调试模式之间的不同行为
问题描述
当我在运行模式下运行以下 python 代码时,响应等于 0,当我在调试模式下运行它时,响应为 127 并且/bin/sh: ping: command not found
发生故障。
cmd = '-c 1'
host = 192.168.1.1
response = subprocess.call(f'ping {cmd} {host}, shell=True')
我的 launch.json 看起来像这样:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
使用时response = os.system(f'ping {cmd} {host}')
,运行模式下响应为0,调试模式下响应为32512,出现故障sh: ping: command not found
。
有人能帮我吗?
解决方案
推荐阅读
- json - 如何只转换为json可以转换的数据?
- mysql - 如何在express.js中使用mysql将n个输入存储到一个数组中
- c# - 如何在没有其他 Nuget 包的情况下打开 zip 文件?
- angular - 延迟加载与 Childroutes 不起作用
- python - 使用 Python re.Search() 查找不允许的字符
- python-3.x - 在 Django 中重复基于类的视图的最佳 DRY 方法是什么?
- apache-kafka - Kafka:动物园管理员和引导服务器之间的主题列表差异
- php - LinkedIn Permissions / API : 显示组织的最后一篇文章
- html - Django分页不显示指向其他页面链接的链接
- csv - 工作表上的 IMPORTDATA() 不适用于驱动器或谷歌存储桶中的文件