Answers for "python os move up 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
1

python how to change back to the later directory

import os
#just write the whole file path in the change directory function
os.chdir('C:User/.../the_name_of_the_directory')
#Just fo check
os.getcwd()
Posted by: Guest on May-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language