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 ...
随机推荐
- 【模板】网络流-最大流模板(Dinic)
#include <cstdio> #include <cstring> #include <algorithm> #include <queue> u ...
- 我的shell脚本
问题:在ip.lt文件中有600个IP,有3个文档模版,三个文档的名称结构都是“ip+一系列字符串”,要求:1.将600个IP分成3分,以三个模版为基础创建600个文档,名字结构与模版相同:2修改60 ...
- 《Linux内核设计与实现》第4章读书笔记
第四章 进程调度 调度程序负责决定将哪个程序投入运行,何时运行以及运行多长时间.进程调度程序可看做在可运行态进程之间分配有限的处理器时间资源的内核子系统.调度程序是像Linux这样的多任务操作系统的基 ...
- struts2练习时犯的错误(2016年11月4日)
1.Tomcat启动时报错 严重: 文档无效: 找不到语法. at (null:3:8) org.xml.sax.SAXParseException; systemId: file:/F:/Progr ...
- listview android:cacheColorHint,android:listSelector属性作用(转)
ListView是常用的显示控件,默认背景是和系统窗口一样的透明色,如果给ListView加上背景图片,或者背景颜色时,滚动时listView会黑掉, 原因是,滚动时,列表里面的view重绘时,用的依 ...
- 关于[x/y]一些小想法
[x/y],即x除以y下取整 (不会LATEX) 1.对于给定的x,对于所有的1<=y<=x, [x/y]一共有√x种取值. 证明: 对于y<=√x,y有根号种,所以值最多根号种.对 ...
- Lowest Common Ancestor in a Binary Tree
二叉树最低公共祖先节点 acmblog If one key is present and other is absent, then it returns the present key as LC ...
- tensorflow变量作用域(variable scope)
举例说明 TensorFlow中的变量一般就是模型的参数.当模型复杂的时候共享变量会无比复杂. 官网给了一个case,当创建两层卷积的过滤器时,每输入一次图片就会创建一次过滤器对应的变量,但是我们希望 ...
- RGB色彩对照表
RGB色彩对照表 #FFFFFF #FFFFF0 #FFFFE0 #FFFF00 #FFFAFA #FFFAF0 #FFFACD #FFF8DC #FFF68F ...
- Linux入门,这七大习惯得有!
对于很多Linux初学者来说,在刚开始使用Linux系统时会感到很多不适.这里为大家整理了自己以前Linux入门时别人告诉我的七个习惯.我相信如果你运用了这七个习惯,在你使用Linux时你会感觉更安全 ...