import os filepath = os.path.join('c:/your/full/path', 'filename') if not os.path.exists('c:/your/full/path'): os.makedirs('c:/your/full/path') f = open(filepath, "a")
f = open(r"C:Test.py", "a")