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
os.path.isdir(path)异常的更多相关文章
- python中os.path.isdir()函数的使用
在python 中,os.path.isdir(path)函数主要用来判断函数内部的path是否为一个目录 具体关于这个函数的解说参考博客https://blog.csdn.net/xjp_xujip ...
- os模块 os.stat('path/filename') os.path.dirname(path) os.path.exists(path) os.path.join(path1[, path2[, ...]])
提供对操作系统进行调用的接口 os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相当于 ...
- python中os.path.isdir()等函数的作用和用法
一 用法和概念: Python中的os模块用于和系统进行交互,其中: 1 os.listdir()用于返回一个由文件名和目录名组成的列表,需要注意的是它接收的参数需要是一个绝对的路径. 2 os.pa ...
- 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: #当前目录,子 ...
- os.path.exists(path) 和 os.path.lexists(path) 的区别
使用os.path.exists()方法可以直接判断文件是否存在.代码如下:>>> import os>>> os.path.exists(r'C:\1.TXT') ...
- os.path.join合并 os.path.dirname返回上一级目录 os.path.exists(path) os.stat('path/filename')获取文件/目录信息
import os str1 = "grsdgfd" str2 = "wddf" str3 = "gddgs" # print(str1 + ...
- 路径操作OS模块和Path类(全)一篇够用!
路径操作 路径操作模块 os模块 os属性 os.name # windows是nt, linux是posix os.uname() # *nix支持 sys.platform #sys模块的属性, ...
- 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 ...
- 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 ...
随机推荐
- 【NOI 2018】冒泡排序(组合数学)
题意大概是给定一个长度为$n$的排列$p$,求有多少长度为$n$的排列满足冒泡排序的交换次数为$\frac{1}{2} \sum\limits_{i = 1}^{n}|i - p_{i}|$. 可以发 ...
- 洛谷 P1199 三国游戏 解题报告
P1199 三国游戏 题目描述 小涵很喜欢电脑游戏,这些天他正在玩一个叫做<三国>的游戏. 在游戏中,小涵和计算机各执一方,组建各自的军队进行对战.游戏中共有\(N\)位武将(\(N\)为 ...
- Java类编译、加载、和执行机制
Java类编译.加载.和执行机制 标签: java 类加载 类编译 类执行 机制 0.前言 个人认为,对于JVM的理解,主要是两大方面内容: Java类的编译.加载和执行. JVM的内存管理和垃圾回收 ...
- 解题:USACO12OPEN Bookshelf
题面 从零开始的DP学习之肆 当DP方程中的一部分具有某种单调性时可以用数据结构或者预处理维护来降低复杂度 一开始没有看懂题,尴尬,后来发现题目可以简化成这个样子: 将一个序列划分为若干段,每段长度不 ...
- IDA error of " positive sp value has been found"
问:用IDA静态分析,函数结尾出现 endp ; sp-analysis failed 用F5调不出伪代码,不知道是什么原因,请问有什么解决办法没有? 答:endp ; sp-analysis fai ...
- centos systemctl daemon-reload 提示 no such file or directory 的一个原因
service 的文件名写错了 比如 mongodb.service 写成了 mongodb.srvice 真的是坑,居然没有提示具体的路径,只是提示一个 no such file or direct ...
- python 字符串切片知识巩固
切片操作(slice)可以从一个字符串中获取子字符串(字符串的一部分).我们使用一对方括号.起始偏移量start.终止偏移量end 以及可选的步长step 来定义一个分片. 格式: [start:en ...
- P1850 换教室
P1850 换教室 现在有一张图, 有 \(v <= 300\) 个节点 你需要从 \(c_{1}\) 到 \(c_{2}\) 到 \(c_{n} (n <= 2000)\) 现在你有 \ ...
- UITableViewCell的separatorInset属性
separatorInset这个属性是IOS7后才有的属性,所以需要判断一下,才能修改 if (IOS7_OR_LATER) { cell.separatorInset = UIEdgeInsetsZ ...
- 张鑫旭:Promise异步编程模式
参考文章: http://www.zhangxinxu.com/wordpress/2014/02/es6-javascript-promise-%E6%84%9F%E6%80%A7%E8%AE%A4 ...