how to check existence of a core files in directory using Python
This question already has an answer here:
Use the built-in glob
module:
import glob
if glob.glob('/path/to/dir/core*'):
print('At least one core file present in /path/to/dir')
More reading here: https://docs.python.org/3/library/glob.html
这可能是愚蠢的,这是解决方案吗?
import os
os.path.isfile(os.path.join(path,corename))
另外os lib可以为你做诡计,返回true或false
import os
os.path.exists(dir_or_file_to_check)