python change to directory of script code example
Example 1: change directory in python script
os.chdir(os.path.dirname(__file__))
Example 2: python change working directory to file directory
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)