'Making username-independent os.rename
I was making a module for my friend, which knows of basically nothing on the coding side of things, so I had a setup.py which will put things from the download folder to the folders the projects need to be in. However, my friend does not know their computer username, so I used
os.getlogin(), but when I try to put the variable I assigned the value to into the file paths, it gives multiple errors.
Here is my current code:
import os
user = os.getlogin()
os.rename(r"C:\Users\"" + user + "\FILEPATH\FILEPATH\FILENAME", r"C:\Users\"" +
user +"\FILEPATH\FILEPATH\FILENAME")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
