![](/img/trans.png)
[英]How to run a Python file in Visual Studio code from the terminal?
[英]How to hide the file path displaying in Visual Studio Code's terminal
在終端中運行我的 python 代碼后,它在第一行顯示了一些路徑,然后在第二行顯示了我的代碼 output。 我可以隱藏第一行以便在第二行只看到 output 嗎?
C:\Users\Venyl\Desktop\VS CODE\Code 2020>C:/Users/Venyl/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/Venyl/Desktop/VS CODE/Code 2020/print('lol').py"
hello world
.vscode
文件夾中的launch.json
中使用以下設置,以及"console":
設置代碼調試結果的顯示方式。
"console": "internalConsole",
設置好后,調試結果會顯示在VSCode內部的“調試控制台”中。
"console": "externalTerminal",
並且調試結果會顯示在 VSCode 外的“cmd”窗口中。 它也只顯示調試結果:
"console": "integratedTerminal",
它在VSCode內部終端顯示結果,並顯示當前環境和運行文件的路徑。參考:控制台。
上面的答案適用於根據需要顯示輸出但是如果你想隱藏長路徑
使用提示 [文本]
例如,以下命令將“>(大於號)”設置為提示
提示 $g
如果您想返回顯示完整路徑,只需鍵入提示並按 Enter。
如果您使用代碼運行器擴展,
打開 settings.json (ctrl + shift + p 然后輸入 settings.json) 然后添加這個
"code-runner.executorMap": {
"python": "<console clear> && <python or your python version> -u",
},
"code-runner.clearPreviousOutput": true,
"code-runner.showExecutionMessage": false,
"code-runner.runInTerminal": true,
在VsCode中下載code-runner extension,然后在code-runner extension的設置中取消勾選Code-runner:Show Execution Message
。 在此處輸入圖像描述
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.