0

So I'm trying to make a specific program (in python) and when I use the path command and say I want to go to the desktop, it's in C:\Users\Myname\Desktop. And if someone else downloads the file it won't be able to path because I do not know the users name.

ConnerWithAnE
  • 1,106
  • 10
  • 26

1 Answers1

0

If you want just username you can use this

os.environ["HOMEPATH"].split("\\")[-1]
# output: Afshar Sharifi

But if you want the whole path to desktop better to use thid

os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop')
# output: C:\Users\Afshar Sharifi\Desktop
Afshar Sharifi
  • 152
  • 1
  • 7