Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change the current working directory in python

import os
cdir = os.getcwd() # it will return current working directory
print("Previous_dir",cdir)
# Previous_dir C:Users..Desktoppython
os.chdir('C:/Users/../Desktop/desire_folder') #chdir used for change direcotry
print("Current_dir",cdir)
# Current_dir C:Users..Desktoppython	eamspirit
Comment

python set current working directory to script location python

import os

os.chdir(os.path.dirname(os.path.abspath(__file__)))
Comment

change working directory python

import os
os.chdir(new_working_directory)
Comment

Change my python working directory

# Import the os module
import os

# Print the current working directory
print("Current working directory: {0}".format(os.getcwd()))

# Change the current working directory
os.chdir('/tmp')

# Print the current working directory
print("Current working directory: {0}".format(os.getcwd()))
Comment

Current working Directory in python

import pathlib

print(pathlib.Path(__file__).parent.absolute())
Comment

set current working directory automatically in Python

import inspect
import os

module_path = inspect.getfile(inspect.currentframe())
module_dir = os.path.realpath(os.path.dirname(module_path))
os.chdir(module_dir)
Comment

PREVIOUS NEXT
Code Example
Python :: how to use the print function in python 
Python :: numpy initialize 2d array 
Python :: selection sort python 
Python :: open and read a file in python 
Python :: django updated_at field 
Python :: get sum in range 
Python :: select rows where column value is in list of values 
Python :: is everything in python an object 
Python :: get all file in folder python 
Python :: passing user instance django form submission 
Python :: create spark dataframe from pandas 
Python :: reverse an array python 
Python :: accept user input in python 
Python :: python turtle commands 
Python :: keras linear regression 
Python :: change x axis frequency 
Python :: change python3 as default for mac 
Python :: python mahalanobis distance 
Python :: in pandas how to start an index from a specific number 
Python :: Python Requests Library Get Method 
Python :: enum python 
Python :: python check if class has function 
Python :: basic tkinter gui 
Python :: dynamic array python numpy 
Python :: python subprocess stdout to dev null 
Python :: keyboard press pyautogui 
Python :: threading.Timer python recurrent 
Python :: python find item in list 
Python :: Clear All the Chat in Discord Channel With Bot Python COde 
Python :: np.random 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =