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

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 :: python program to shutdown computer when user is not present 
Python :: how to read tsv file python 
Python :: tensorflow history plot 
Python :: reindex pandas dataframe from 0 
Python :: majority in array python 
Python :: how to save a png seaborn pandas 
Python :: sklearn plot confusion matrix 
Python :: install easygui 
Python :: dataframe from two series 
Python :: python password generator 
Python :: draw a line pygame 
Python :: how to open an external file in python 
Python :: SettingWithCopyWarning 
Python :: random pick any file from directory python 
Python :: combination python 
Python :: How to print list without for loop python 
Python :: random gen in python 
Python :: selenium-screenshot python 
Python :: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123) 
Python :: how to get a random element from an array in python 
Python :: df.drop index 
Python :: python install required packages 
Python :: how to remove plotly toolbar 
Python :: python diamond print 
Python :: install python3 centos 7.8 
Python :: string of numbers to list of integers python 
Python :: python get ros package path 
Python :: add all string elements in list python 
Python :: pandas append dictionary to dataframe 
Python :: python check ram usage 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =