Test File Path in Python on Windows - DevPops-Inc/windows GitHub Wiki

• Press the Windows key type “python” and select the “IDLE” application.
image

• Type import os and press the “Enter” key to import the os module.
image

• Type from pathlib import PureWindowsPath and press the Enter key to import the PureWindowsPath object from the pathlib module.
image

• Type variable = PureWindowsPath(“< file path >”) and press the Enter key to declare a variable and set its value as the file path you wish to test.
image

• Type os.path.exists(< variable >) and press the Enter key to test the file path and it will return either True or False.
image

• Type exit() or quit() and press the “Enter” key to exit the IDLE interactive shell. / • image

• Select “OK.”
image

⚠️ **GitHub.com Fallback** ⚠️