How can I change drives using python os?

别来无恙 提交于 2019-12-05 07:07:21

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()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!