python os.path.exists 已存在_python中的os.path.exists和os.path.isfile之间的区别

I'm curious when these two functions will return different values. Also if you could clarify the difference between a path/directory/file that would be appreciated.

解决方案

As you have already found out, the difference between exists and isfile is the fact that the former returns True in case the given path is a directory or a file, while the latter only returns True if the path points to a file.

Directories and files are quite similar from the technical point of view. A file can contain any kind of data. A directory is just a special entry in the file system (at least on Unix operating systems it is just a special file) that represents the fact that it may contain files and other directories. It is a helpful means for building up a data structure. Using directories, you can organize your data in a hierarchical structure.

Especially in the Windows world, directories are often called "folders". I am sure that you yourself are using "folders" for organizing your files.

A path is an unambiguous pointer to a resource in the file system. It can either point to a file or to a directory.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值