New to Python and using v3. Trying to find any function that lets me test and validate a passed-in string to see if it represents a file or a folder, and if so, if that file/folder actually exists on disk. I don't need to do anything with that file or folder, just to check if it exists or not for some 'if' logic.
I have recently found the following imports...
import os
import pathlib
and they look promising, but the examples I've found look like they're actually trying to open/load them, not simply check if they exist, and I haven't found anything to see if the string represents a valid format for a directory or file in the first place.
New to Python and using v3. Trying to find any function that lets me test and validate a passed-in string to see if it represents a file or a folder, and if so, if that file/folder actually exists on disk. I don't need to do anything with that file or folder, just to check if it exists or not for some 'if' logic.
I have recently found the following imports...
import os
import pathlib
and they look promising, but the examples I've found look like they're actually trying to open/load them, not simply check if they exist, and I haven't found anything to see if the string represents a valid format for a directory or file in the first place.
New to Python and using v3. Trying to find any function that lets me test and validate a passed-in string to see if it represents a file or a folder, and if so, if that file/folder actually exists on disk. I don't need to do anything with that file or folder, just to check if it exists or not for some 'if' logic.
I have recently found the following imports...
import os
import pathlib
and they look promising, but the examples I've found look like they're actually trying to open/load them, not simply check if they exist, and I haven't found anything to see if the string represents a valid format for a directory or file in the first place.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.