[Python] How to get Desktop location?

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Python on Windows and I want a part of my script to copy a file from a certain directory (I know its path) to the Desktop.

    I used this:

    shutil.copy(txtName, '%HOMEPATH%/desktop')


    While txtName is the txt File's name (with full path).

    I get the error:

    IOError: [Errno 2] No such file or directory: '%HOMEPATH%/DESKTOP'


    Any help?

    I want the script to work on any computer.

    Continue reading...

Compartilhe esta Página