pythonoperating-system

How to find path to desktop in python


I am new to the os library and I was wondering how I could find the path for any user who uses windows and access their desktop directory using python. Thanks in advance!


Solution

  • You can do it by using os.environ mapping and add the Desktop path

    import os
    print(os.environ['USERPROFILE'] + '\Desktop')