随笔分类 -  os

摘要:os.path.splitext:分离文件名和扩展名 os.path.split:分离文件路径和文件名 split返回的是一个数组,即使只包含一个值,也要给出索引号 阅读全文
posted @ 2020-09-13 10:23 6+0 阅读(168) 评论(0) 推荐(0)
摘要:获得当前工作的工作路径 阅读全文
posted @ 2020-08-04 22:05 6+0 阅读(70) 评论(0) 推荐(0)
摘要:1、mkdir 创建一级目录 2、makedirs 创建多级目录 阅读全文
posted @ 2020-08-04 21:52 6+0 阅读(187) 评论(0) 推荐(0)
摘要:path = '/Users/liujianing/PycharmProjects'print(path)for dirpath, dirnames, filenames in os.walk(path): print('dirpath:') print(dirpath) print('dirnam 阅读全文
posted @ 2020-08-04 19:56 6+0 阅读(164) 评论(0) 推荐(0)
摘要:os.listdir(path) 返回path路径下的文件和文件夹列表,不是文件或文件夹路径的列表,参数path必须是一个路径,而不能是一个普通的字符串 一般获取到之后都是要拼接成路径 阅读全文
posted @ 2020-07-19 22:39 6+0 阅读(260) 评论(0) 推荐(0)
摘要:os.path.join(path, paths) 可以将多个路径拼接在一起 阅读全文
posted @ 2020-07-19 22:32 6+0 阅读(258) 评论(0) 推荐(0)
摘要:1、文件夹或文件os.path.exists('models')2、文件os.path.isfile('models/linear.pth') 阅读全文
posted @ 2020-06-15 20:40 6+0 阅读(520) 评论(0) 推荐(0)