一只甜甜圈
在os.path模块中有个isfile的方法,该方法可以判断是不是文件,返回True说明是文件,返回False则不是文件,下面的英文是摘自python文档os.path.isfile(path)Return True if path is an existing regular file. This follows symbolic links, so both islink() and isfile() can be true for the same path.用法也很简单123import osfilename='/tmp/test.txt'print os.path.isfile(filename)