سؤال

What i'am trying to figure out is , how do i refer to a path which changes from system to system. An example:

System A:

C:\Users\User1\AppData\Roaming

System B:

C:\Users\User2\AppData\Roaming

Basically i'm trying to figure out how to deal when the user profile changes. How do i refer to a file/folder in this case?

هل كانت مفيدة؟

المحلول

You can get the current user's profile path from the APPDATA environment variable.

os.environ["APPDATA"] # returns "c:\\Users\\<username>\\AppData\\Roaming"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top