代码拉取完成,页面将自动刷新
#!/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"))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。