Answers for "pytohn os change working directory"

1

python change working directory to file directory

import os

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
Posted by: Guest on March-23-2021
0

Changing the Current Working Directory in Python

# 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('/Projects')

# Print the current working directory
print("New Current working directory: {0}".format(os.getcwd()))
Posted by: Guest on September-25-2021

Code answers related to "pytohn os change working directory"

Python Answers by Framework

Browse Popular Code Answers by Language