I am currently working on a script that does some things to Windows directories and I can’t seem to figure out what I am doing wrong. Here is the relevant excerpt of the code.
import os
user = os.environ['USERNAME']
os.chdir("/users/%s/dekstop") % user
But when I do that, it gives the the following error,
WindowsError: [Error 3] The system cannot find the path specified: '/users/%s/desktop'
Is there a reason why the string formatting wouldn’t be working?
The
% usersshould be within the parentheses:os.chdir("/users/%s/dekstop" % user)