cd directory python code example Example 1: working directory python import os cwd = os.getcwd() Example 2: python cd to directory import os os.chdir(path)