国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

python3中os.path模塊下常用的用法總結(jié)【推薦】

2020-02-15 22:57:52
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

abspath

返回一個(gè)目錄的絕對(duì)路徑Return an absolute path.>>> os.path.abspath("/etc/sysconfig/selinux")'/etc/sysconfig/selinux'>>> os.getcwd()'/root'>>> os.path.abspath("python_modu")'/root/python_modu'

basename

返回一個(gè)目錄的基名Returns the final component of a pathname>>> os.path.basename("/etc/sysconfig/selinux")'selinux'>>> os.path.basename("/usr/local/python3/bin/python3")'python3'

dirname

返回一個(gè)目錄的目錄名Returns the directory component of a pathname>>> os.path.dirname("/etc/sysconfig/selinux")'/etc/sysconfig'>>> os.path.dirname("/usr/local/python3/bin/python3")'/usr/local/python3/bin'

exists

測(cè)試指定文件是否存在Test whether a path exists. Returns False for broken symbolic links>>> os.path.exists("/home/egon")False>>> os.path.exists("/root")True>>> os.path.exists("/usr/bin/python")True

getatime

得到指定文件最后一次的訪問(wèn)時(shí)間Return the last access time of a file, reported by os.stat().>>> os.stat("/root/test.sh")os.stat_result(st_mode=33261, st_ino=100684935, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=568, st_atime=1498117664, st_mtime=1496629059, st_ctime=1498117696)>>> os.path.getatime("/root/test.sh")1498117664.2808378

getctime

得到指定文件最后一次的改變時(shí)間Return the metadata change time of a file, reported by os.stat().>>> os.stat("/root/test.sh")os.stat_result(st_mode=33261, st_ino=100684935, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=568, st_atime=1498117664, st_mtime=1496629059, st_ctime=1498117696)>>> os.path.getctime("/root/test.sh")1498117696.039542

getmtime

得到指定文件最后一次的修改時(shí)間Return the last modification time of a file, reported by os.stat().>>> os.stat("/root/test.sh")os.stat_result(st_mode=33261, st_ino=100684935, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=568, st_atime=1498117664, st_mtime=1496629059, st_ctime=1498117696)>>> os.path.getmtime("/root/test.sh")1496629059.9313989

getsize

得到得到文件的大小Return the size of a file, reported by os.stat().>>> os.stat("/root/test.sh")os.stat_result(st_mode=33261, st_ino=100684935, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=568, st_atime=1498117664, st_mtime=1496629059, st_ctime=1498117696)>>> os.path.getsize("/root/test.sh")568

isabs

測(cè)試參數(shù)是否是絕對(duì)路徑Test whether a path is absolute>>> os.path.isabs("python_modu")False>>> os.path.isabs("/etc/sysconfig")True
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 庆云县| 江阴市| 南投市| 杭锦后旗| 上犹县| 嘉峪关市| 金华市| 华容县| 富锦市| 汝南县| 七台河市| 铁岭市| 古田县| 宝应县| 罗定市| 山西省| 永平县| 阳春市| 金华市| 綦江县| 绥滨县| 平和县| 关岭| 东兰县| 集安市| 沅陵县| 马关县| 道真| 海盐县| 柳河县| 抚宁县| 城步| 柏乡县| 谢通门县| 贵州省| 肇州县| 钟山县| 尼玛县| 厦门市| 鄂州市| 沙田区|