Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the current working directory? [duplicate]

How to set the current working directory in Python?

like image 797
ricardo Avatar asked Nov 27 '09 21:11

ricardo


People also ask

How do I change my current working directory?

To change the current working directory(CWD) os. chdir() method is used. This method changes the CWD to a specified path. It only takes a single argument as a new directory path.

How do I copy a working directory in Linux?

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied.

How do I change the current working directory in Python?

To find the current working directory in Python, use os. getcwd() , and to change the current working directory, use os. chdir(path) .


2 Answers

Try os.chdir

os.chdir(path) 

        Change the current working directory to path. Availability: Unix, Windows.

like image 87
Mark Byers Avatar answered Sep 24 '22 15:09

Mark Byers


Perhaps this is what you are looking for:

import os os.chdir(default_path) 
like image 25
unutbu Avatar answered Sep 24 '22 15:09

unutbu