2017年11月30日
摘要: python os.path模块 os.path.abspath(path) #返回绝对路径 os.path.basename(path) #返回文件名 os.path.commonprefix(list) #返回list(多个路径)中,所有path共有的最长的路径。 os.path.dirname 阅读全文
posted @ 2017-11-30 18:50 gis木棉鱼 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 创建目录 os.mkdir() 在Python中可以使用os.mkdir()函数创建目录(创建一级目录)。 其原型如下所示: os.mkdir(path) 其参数path 为要创建目录的路径。 例如要在D盘下创建hello的目录 >>> import os >>> os.mkdir('d:\hell 阅读全文
posted @ 2017-11-30 13:47 gis木棉鱼 阅读(221) 评论(0) 推荐(0) 编辑
摘要: if name.endswith(".tmp"): os.remove(os.path.join(root, name)) 补充: 函数:endswith() 作用:判断字符串是否以指定字符或子字符串结尾,常用于判断文件类型 相关函数:判断字符串开头 startswith() 一、函数说明 语法:s 阅读全文
posted @ 2017-11-30 13:15 gis木棉鱼 阅读(246) 评论(0) 推荐(0) 编辑
摘要: for root , dirs, files in os.walk(path): 知识点: 代码中的root为str类型,dirs为list类型,files为list类型 当root为/test时,dirs列表中是/test下的目录,files列表是/test下的文件 当root为/test/aa时 阅读全文
posted @ 2017-11-30 12:59 gis木棉鱼 阅读(717) 评论(1) 推荐(0) 编辑
摘要: 要点: 1. arcpy.mapping.MapDocument(路径) 2.os.sep表示\ ;os.path.basename(i)表示带路径的文件名 阅读全文
posted @ 2017-11-30 11:21 gis木棉鱼 阅读(1679) 评论(2) 推荐(0) 编辑