How can I change drives using python os?
Are you sure Y:
really is a valid drive letter?
Try os.chdir('C:')
and make sure that works. (It works for me.)
If this is a mapped network drive, your best bet is to use the UNC path instead of the mapped path. Also, try to use a raw r
string modifier when using paths under windows, if you're not using os.path.join
.
import os
print os.getcwd()
os.chdir(r'\\server\path')
print os.getcwd()