Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python os.chdir() doesn't seem to work

I can't seem to change my directory in python:

import os

os.getcwd()

'C:\\Users\\Jon\\Folder\\IdbyGenotype'

os.chdir(r"C:\Users\Jon\Folder\IdbyGenotype\thisone")

os.getcwd()

'C:\\Users\\Jon\\Folder\\IdbyGenotype'

Am I missing something? What could be going wrong here?

Thanks

like image 993
hylaeus Avatar asked Aug 14 '13 18:08

hylaeus


1 Answers

Use forward-slash(/) in path whether you are using Windows or Linux

import os

os.getcwd()

'C:\\Users\\Jon\\Folder\\IdbyGenotype'

os.chdir("C:/Users/Jon/Folder/IdbyGenotype/thisone")

This worked in my case.

like image 173
Gajal Shankar Avatar answered Sep 28 '22 07:09

Gajal Shankar