I know how to check whether required arguments are given on the command line. But how do I check whether the given argument on the command line actually refers to an existing file in the folder I'm running the code in?
I'm trying to incorporate this verification in order to save time by skipping parts of my code in case the file cannot be referenced to.
import os
os.path.exists(path)
Will return True, if the path exists.
os.path.isfile(path)
Will return True, if the path is a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With