This is not a short path, it is an environment variable. Using variables is of course more general. Hard-coded things can only work on your own machine.
Take the python you mentioned as a small example. You wrote a clear.py script file, whose function is to clean up the user's system temporary folder. If you don’t use variables, you might write it like this (pseudocode)
del C:\Users\adminstrator\AppData\Local\Temp\*.*
A script like yours cannot be run on other people’s machines. First of all, you need to know the currently logged-in user name, and you have to call the API to know the user’s Temp folder path (maybe on the D drive or E drive) Possibly)
But if you use the system’s default %TEMP% variable, you don’t need to worry about it
To enhance program portability. For example, whether your Windows is installed on the C drive, D drive, or some X drive, the program can be accessed through a short path without the need to hard code the specific path.
The actual installation directories of different computers are not necessarily the same. For example, some of the same software is installed on the c drive and some on the d drive. The actual location is saved through such an environment variable. The program only needs to access the environment variable. , which can enhance the portability of the program.
This is not a short path, it is an environment variable.
Using variables is of course more general. Hard-coded things can only work on your own machine.
Take the python you mentioned as a small example. You wrote a clear.py script file, whose function is to clean up the user's system temporary folder.
If you don’t use variables, you might write it like this (pseudocode)
A script like yours cannot be run on other people’s machines. First of all, you need to know the currently logged-in user name, and you have to call the API to know the user’s Temp folder path (maybe on the D drive or E drive) Possibly)
But if you use the system’s default %TEMP% variable, you don’t need to worry about it
To enhance program portability. For example, whether your Windows is installed on the C drive, D drive, or some X drive, the program can be accessed through a short path without the need to hard code the specific path.
The actual installation directories of different computers are not necessarily the same. For example, some of the same software is installed on the c drive and some on the d drive. The actual location is saved through such an environment variable. The program only needs to access the environment variable. , which can enhance the portability of the program.