Ai
1 Star 3 Fork 6

DivingKitten/PyDesignPattern

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
DRY.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Spencer.Luo 提交于 2018-11-11 22:27 +08:00 . Modify Principle
#!/usr/bin/python
# Authoer: Spencer.Luo
# Date: 8/11/2018
# import os
# # 导入os库,用于文件、路径相关的解析
# def getPath(basePath, fileName):
# extName = os.path.splitext(fileName)[1]
# filePath = basePath
# if(extName.lower() == ".txt"):
# filePath += "/txt/"
# elif(extName.lower() == ".pdf"):
# filePath += "/pdf/"
# else:
# filePath += "/other/"
#
# # 如果目录不存在,则创建新目录
# if (not os.path.exists(filePath)):
# os.makedirs(filePath)
#
# filePath += fileName
# return filePath
import os
# 导入os库,用于文件、路径相关的解析
def getPath(basePath, fileName):
extName = fileName.split(".")[1]
filePath = basePath + "/" + extName + "/"
# 如果目录不存在,则创建新目录
if (not os.path.exists(filePath)):
os.makedirs(filePath)
filePath += fileName
return filePath
print(getPath("E:/upload", "TestFile.rar"))
print(getPath("E:/upload", "Design Pattern for Python.pdf"))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/divingkitten/PyDesignPattern.git
git@gitee.com:divingkitten/PyDesignPattern.git
divingkitten
PyDesignPattern
PyDesignPattern
master

搜索帮助