展开全部
look~~
>>> os.path.exists("te")
True
>>> os.path.exists("nothing")
False
>>> os.path.isfile("nothing")
False
>>> os.path.isdir("nothing")
False
>>>
>>> os.path.isdir("te")
False
>>> os.path.isfile("te")
True
>>>
建议2113你先判断是否存在,如果确5261实存在,你再进行判断是文件还4102是文件夹1653
-------------------------
Linux,文件夹名和同级目录的文件名是不可以同时存在的。zhangzhipeng@Earth:~$ mkdir te
mkdir: cannot create directory `te': File exists
zhangzhipeng@Earth:~$ rm te
zhangzhipeng@Earth:~$ mkdir te
zhangzhipeng@Earth:~$ > te
-bash: te: Is a directory
--------------------------
windows中:
可以证明,不管windows还是linux,同级目录下,是不允许出现同名文件(夹)的
但是这不能代表不是文件就是文件夹啊,首先得确认这个文件(夹)是存在的。
其实,文件夹也是一个文件。