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

os.path.isdir(path)异常的更多相关文章

  1. python中os.path.isdir()函数的使用

    在python 中,os.path.isdir(path)函数主要用来判断函数内部的path是否为一个目录 具体关于这个函数的解说参考博客https://blog.csdn.net/xjp_xujip ...

  2. os模块 os.stat('path/filename') os.path.dirname(path) os.path.exists(path)  os.path.join(path1[, path2[, ...]])

    提供对操作系统进行调用的接口 os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname")  改变当前脚本工作目录:相当于 ...

  3. python中os.path.isdir()等函数的作用和用法

    一 用法和概念: Python中的os模块用于和系统进行交互,其中: 1 os.listdir()用于返回一个由文件名和目录名组成的列表,需要注意的是它接收的参数需要是一个绝对的路径. 2 os.pa ...

  4. python获取某路径下,某种特定类型的文件名称,os.walk(路径)生成器;os.listdir(路径),os.path.splitext(名称),os.path.join(路径,名称),os.path.isdir(路径\名称)

    #获取某文件夹下制定类型文件# import os# def filep(fp):# l=[]# a=os.walk(fp) #生成器# for nowp,sonp,oth in a: #当前目录,子 ...

  5. os.path.exists(path) 和 os.path.lexists(path) 的区别

    使用os.path.exists()方法可以直接判断文件是否存在.代码如下:>>> import os>>> os.path.exists(r'C:\1.TXT') ...

  6. os.path.join合并 os.path.dirname返回上一级目录 os.path.exists(path) os.stat('path/filename')获取文件/目录信息

    import os str1 = "grsdgfd" str2 = "wddf" str3 = "gddgs" # print(str1 + ...

  7. 路径操作OS模块和Path类(全)一篇够用!

    路径操作 路径操作模块 os模块 os属性 os.name # windows是nt, linux是posix os.uname() # *nix支持 sys.platform #sys模块的属性, ...

  8. Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64

    编译项目报错: Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch ...

  9. difference in physical path, root path, virutal path, relative virtual path, application path and aboslute path?

    http://stackoverflow.com/questions/13869817/difference-in-physical-path-root-path-virutal-path-relat ...

随机推荐

  1. 【BZOJ3064】CPU监控(线段树)

    [BZOJ3064]CPU监控(线段树) 题面 BZOJ 洛谷 题解 神仙\(zsy\)出在了\(noip\)模拟的题目.(然而\(zsy\)出的还是这题的升级版) 首先明确一点,这题是一个吉司机线段 ...

  2. Nginx访问日志分析

    nginx默认的日志格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$sta ...

  3. hadoop进阶----hadoop经验(一)-----生产环境hadoop部署在超大内存服务器的虚拟机集群上vs几个内存较小的物理机

    生产环境 hadoop部署在超大内存服务器的虚拟机集群上 好 还是  几个内存较小的物理机上好? 虚拟机集群优点 虚拟化会带来一些其他方面的功能. 资源隔离.有些集群是专用的,比如给你三台设备只跑一个 ...

  4. 使用JS在textarea在光标处插入内容

    // 在光标处插入字符串 // myField 文本框对象 // myValue 要插入的值 function insertAtCursor(myField, myValue) { //IE supp ...

  5. Python【sys】模块和【hashlib】模块

    import sysimport osprint(sys.platform) #判断操作系统,windows10输出win32print("sys.path:",sys.path) ...

  6. Jenkins+Maven+SVN

    准备环境: CentOS7 JDK1.7.9.0_79 Maven3.3.9 Jenkins2.5.0 1.配置jdk环境变量 2.安装maven(否则在创建job时没有maven选项) unzip ...

  7. Tomcat权威指南-读书摘要系列3

    3. 在Tomcat中部署Servlet与JSP Web应用程序 jar命令打包war文件 jar cvf examples.war .

  8. Hadoop基础-序列化与反序列化(实现Writable接口)

    Hadoop基础-序列化与反序列化(实现Writable接口) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.序列化简介 1>.什么是序列化 序列化也称串行化,是将结构化 ...

  9. 转:Xcode 删除文件后编译出现的missing file的警告

    进入“Missing File”对应的目录进行删除即可. 1.由于使用SVN导致的,可进行如下操作: # cd ~/iHost/Demo/sfsimonutility/SFSimonUtility/S ...

  10. 戴尔R720xd服务器系统安装前期环境实现

    型号:R720xd 开启服务器,Ctrl+R进入raid配置 配置完raid后F2对硬盘进行格式化 保存并重启 F11进入BIOS选项设置U盘启动 选择U盘启动 开始进行系统安装!