Created
September 24, 2021 06:58
-
-
Save SaraM92/40a530cf0f776c9aed61bc0dae6869b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Checking if a file exists in two ways | |
#1- Using the OS module | |
import os | |
exists = os.path.isfile('/path/to/file') | |
#2- Use the pathlib module for a better performance | |
from pathlib import Path | |
config = Path('/path/to/file') | |
if config.is_file(): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment