Answer the question
In order to leave comments, you need to log in
How to create a variable for a folder on a computer?
How to make a variable that will always type in the same path on any computer? Let's say a variable that on any computer will indicate the path to the AppData/Roaming folder.
Answer the question
In order to leave comments, you need to log in
Well, "on any computer" is a strong word. Still, the computer may not be windows.
But you have two options.
First, there is the %APPDATA% environment variable, which stores the path to AppData/Roaming for the current user. See os.environ .
Secondly, there is the win32com module, which allows you to use COM modules for Windows, incl. provided by the system. One of them deals with the paths to standard folders.
from win32com.shell import shell, shellcon
#путь к "мои документы". можно задавать разные константы CSIDL_XXX
doc_folder = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question