The program is based on the owner we have to return the absolute path of files from the path specified, the path specified can be from any directory. This program has to be done in python using windows.
Asked
Active
Viewed 120 times
0
-
Does this answer your question? [Howto determine file owner on windows using python without pywin32](https://stackoverflow.com/questions/8086412/howto-determine-file-owner-on-windows-using-python-without-pywin32) – dboy May 25 '20 at 05:53
-
@dboy OP is not talking about file ownership – medic17 May 25 '20 at 05:59
2 Answers
0
I think this might be what you are looking for
import os
print(os.getcwd())
This prints out the current working directory, which includes the name of the user which I'm guessing is what you are after.

Mandera
- 2,647
- 3
- 21
- 26
-
-
Yeah did you try it? I thought you needed the "user id" to construct the absolute path, but this gives you the absolute path directly – Mandera May 25 '20 at 05:56
-
python prog.py /home/user -owner "deep123" like this I will be giving in the command-line argument. In my program file I will be giving the path and some owner name based on that it should return the file absolute path. – Deepthi krishnamurthi May 25 '20 at 05:58
-
0
If you just want the username
import os
os.getlogin()

medic17
- 415
- 5
- 16
-
for getting the owner id. like pwd will be using for Linux what for windows? – Deepthi krishnamurthi May 25 '20 at 05:54
-
no this gets you the user name like you asked for. @Mandera has the best way for working directory path – medic17 May 25 '20 at 05:58