DanCouper
0
Q:

os.chdir python

os.chdir("directory name")
3
os.chdir(os.path.dirname(__file__))
0
# Python program to explain os.environ object  
  
# importing os module  
import os 
  
# Get the value of 
# 'HOME' environment variable 
home = os.environ['HOME'] 
  
# Print the value of 
# 'HOME' environment variable 
print("HOME:", home) 
  
# Get the value of 
# 'JAVA_HOME' environment variable 
# using get operation of dictionary 
java_home = os.environ.get('JAVA_HOME') 
  
# Print the value of 
# 'JAVA_HOME' environment variable 
print("JAVA_HOME:", java_home) 
-1
# Python program to explain os.rmdir() method  
    
# importing os module  
import os 
  
# Directory name 
directory = "ihritik"
  
# Parent Directory 
parent = "/home/User/Documents"
  
# Path 
path = os.path.join(parent, directory) 
  
# Remove the Directory 
# "ihritik" 
os.rmdir(path) 
print("Directory '%s' has been removed successfully" %directory) 
-1

New to Communities?

Join the community