0
Q:

python os.environ

#the os module provides an operating system interface from Python
import os
#prints the name of the operating system
print(os.name)
#prints the absolute path for the module
print(os.getcwd())
3
# Driver function 
import os 
if __name__ == "__main__": 
    for (root,dirs,files) in os.walk('Test', topdown=true): 
        print root 
        print dirs 
        print files 
        print '--------------------------------'
-3
# 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
import os 
fd = "GFG.txt"
os.rename(fd,'New.txt') 
os.rename(fd,'New.txt')
-2

New to Communities?

Join the community