1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why does cls in Visual Studio Code Runner only work when CMD is the Terminal Profile...

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I'm currently using VS Code and I'm trying to make it so that when I run my code, it clears any content in the terminal and it begins from the top. The issue is that when I do this with PowerShell as my terminal profile, it just gives me the shell instead of the code I'm trying to run.

    Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>

    To clear the content and have it start from the top in the terminal I'm using cls in the settings.json file under "code-runner.executorMap" like so.

    "python": "cls && python -u" when by default it's just "python": "python -u".

    I was expecting this to work fine since cls does the same thing in either a PowerShell or Command Prompt terminal directly, so why is it that when ran through Code Runner on VS Code, it seems to act like this?

    When I tried using Command Prompt as the terminal profile, it runs my code just fine, but I was wondering if I could get the PowerShell terminal working the same way, and why cls doesn't work with it. I don't have "Clear Previous Output" or "Clear Before Reusing" selected since they only clear the content, but any new lines are still where they would be if that old content was still there.

    Continue reading...

Compartilhe esta Página