I am making a python script as a school project but I have been using my own user in order to use a file path, but I want to make it so that I can use this program on other devices, please, can someone help
Asked
Active
Viewed 29 times
1 Answers
0
You can use the os library for this.
import os
user_name = os.getlogin()
os.getlogin() returns the currently logged in user's user name as a string. Here is the documentation.

Erik Wiström
- 26
- 3
-
thank you, I appreciate the great answer and surprisingly fast response – verwro Oct 22 '22 at 15:48
-
No problem, good luck with your project! Consider accepting the answer if it helped you. – Erik Wiström Oct 22 '22 at 15:56