os.path.isdir(path)异常
Window 10家庭中文版,Python 3.6.4,
当一个路径以多个斜杠(/)或反斜杠字符(\\)结尾时,os.path.isdir(path)函数仍然将它们判断为目录:
>>> os.path.isdir('C:/Python36/Lib/sqlite3//')
True
>>> os.path.isdir('C:/Python36/Lib/sqlite3///')
True
>>> os.path.isdir('C:/Python36/Lib/sqlite3///////')
True
>>> os.path.isdir('C:\\Python36\\Lib\\sqlite3\\\\\\\\') # 8个反斜杠(转义后是4个反斜杠 )
True
孤的判断是返回False的,为何会如此?后续会继续dig~
----
Python官文信息:
os.path.isdir(path)
Return True if path is an existing directory. This follows symbolic links, so both islink() and isdir() can be true for the same path.
path-like object
An object representing a file system path. A path-like object is either a str or bytes object representing a path, or an object implementing the os.PathLike protocol. An object that supports the os.PathLike protocol can be converted to a str or bytes file system path by calling the os.fspath() function; os.fsdecode() and os.fsencode() can be used to guarantee a str or bytes result instead, respectively. Introduced by PEP 519.
class os.PathLike
An abstract base class for objects representing a file system path, e.g. pathlib.PurePath.
PEP 519 -- Adding a file system path protocol
最新文章
- Android图片开发内幕--基础篇
- 第十一篇 Integration Services:日志记录
- DNA repair - HDU 2457(自动机+dp)
- NET基础课--组件2
- C# 计算器 运算符和数字键的keys对照
- 扩展SpringMVC以支持绑定JSON格式的请求参数
- AI繁荣下的隐忧——Google Tensorflow安全风险剖析
- Linux下编译安装php7.2
- 从0开始用U盘制作启动盘装Windows10系统(联想R720笔记本)并永久激活方法
- CodeForces - 314C Sereja and Subsequences (树状数组+dp)
- 软件测试3gkd
- HTTPS SSL &; TLS
- nginx 做数据仓库时,location 404 Not Found,发现找不到要用的数据报:Not Found
- 在SharePoint Server 2010中更改“我的网站”
- ROS知识(2)----理解ROS系统结构
- asp.net MVC 统计在线人数功能实现
- lxd&;openstack-lxd源码剖析
- erl_0021 erlang和java的内存模型比较(引用)
- 解决linux下python多版本兼容问题?
- mongodb聚合(转)
热门文章
- Longest Word in Dictionary through Deleting - LeetCode
- 20135239益西拉姆 Linux内核分析 进程的描述和进程的创建
- Java ConcurrentModificationException 异常分析与解决方案
- 解题:APIO 2014 序列分割
- Centos Python3安装共存
- python小专题——urllib2模块
- Hibernate中常见问题 No row with the given identifier exists问题
- POI导入excel文件2
- linux命令总结之route命令
- python 生成器和迭代器介绍