当前位置: 首页 > news >正文

自己怎么做彩票投注网站常德今日头条新闻

自己怎么做彩票投注网站,常德今日头条新闻,如何将网站指向404,web of science完成了文件自动分类的操作后,我们一起来复习下: 首先,获取文件夹中所有文件名称,用 os.path.join() 函数拼接出要移动到的目标地址。然后,使用 os.path.exists() 函数判断目标文件夹是否存在,不存在用 os.m…

完成了文件自动分类的操作后,我们一起来复习下:

首先,获取文件夹中所有文件名称,用 os.path.join() 函数拼接出要移动到的目标地址。然后,使用 os.path.exists() 函数判断目标文件夹是否存在,不存在用 os.mkdir() 创建文件夹。再者,使用 os.path.isdir() 函数判断是否为文件夹。最后,当不是文件夹时,使用 shutil.move() 函数移动。

# 使用import导入os模块

import os

# 使用import导入shutil模块

import shutil

# 将阿文的下载文件夹路径 /Users/yequ/Desktop 赋值给变量desktopPath

desktopPath = "/Users/yequ/Desktop"

# 使用os.listdir()函数获取该路径下所有的文件(夹),并赋值给变量allItems

allItems = os.listdir(desktopPath)

# 使用for循环遍历所有文件(夹)

for item in allItems:

    # 获取文件后缀名

    extension = os.path.splitext(item)[1].lower()

    # 定义一个变量targetPath,用来表示准备移动到的文件夹路径

    targetPath = ""

    if extension in [".jpg", ".jpeg", ".gif", ".png", ".bmp"]:

        # 使用os.path.join()函数拼接分类文件夹路径:图片文件

        # 并赋值给变量targetPath

        targetPath = os.path.join(desktopPath, "图片文件")

    elif extension in [".avi", ".mp4", ".wmv", ".mov", ".flv"]:

        # 使用os.path.join()函数拼接分类文件夹路径:视频文件

        # 并赋值给变量targetPath

        targetPath = os.path.join(desktopPath, "视频文件")

    elif extension in [".wav", ".mp3", ".mid", ".ape", ".flac"]:

        # 使用os.path.join()函数拼接分类文件夹路径:音频文件

        targetPath = os.path.join(desktopPath, "音频文件")

    elif extension in [".pdf"]:

        # 使用os.path.join()函数拼接分类文件夹路径:PDF文件

        targetPath = os.path.join(desktopPath, "PDF文件")

    elif extension in [".docx", ".doc"]:

        # 使用os.path.join()函数拼接分类文件夹路径:Word文件

        targetPath = os.path.join(desktopPath, "Word文件")

    elif extension in [".xlsx", ".xls"]:

        # 使用os.path.join()函数拼接分类文件夹路径:Excel文件

        targetPath = os.path.join(desktopPath, "Excel文件")

    elif extension in [".pptx", ".ppt"]:

        # 使用os.path.join()函数拼接分类文件夹路径:PPT文件

        targetPath = os.path.join(desktopPath, "PPT文件")

    else:

        # 使用os.path.join()函数拼接分类文件夹路径:其他文件

        targetPath = os.path.join(desktopPath, "其他文件")

    # 判断当如果目标文件夹不存在

    if not os.path.exists(targetPath):

        # 使用os.mkdir()函数创建文件夹

        os.mkdir(targetPath)

    # 使用os.path.join()函数拼接desktopPath和文件名

    # 并赋值给变量itemPath

    itemPath = os.path.join(desktopPath, item)

    # 判断当itemPath不是文件夹时。

    if not os.path.isdir(itemPath):

        # 使用shutil.move()函数移动文件到targetPath路径

        shutil.move(itemPath, targetPath)

http://www.qdjiajiao.com/news/6332.html

相关文章:

  • 木鱼的网站在线外链推广
  • hbuilder网页制作模板网站优化排名软件
  • 南宁微信网站建设网络推广策划方案模板
  • 厦门专业网站建设代理百度收录的网站多久更新一次
  • 长寿网站制作白山网络推广
  • 什么是b s网站开发模式百度竞价项目
  • 绵阳市建设工程监督网站关键词网站排名软件
  • 大数据营销分析seo排名软件怎么做
  • 化妆品网站做的好的搜索引擎提交入口大全
  • 专做短篇的网站网站买卖交易平台
  • 上海网站建设网站制作b2b和b2c是什么意思
  • 专用主机网站建设建网站需要什么条件
  • 网站备案由别人代sem模型
  • 淘宝网站怎么做视频seo视频网页入口网站推广
  • 永久f194078w78w泉州seo按天计费
  • 南宁做网站推广的公司哪家好2022最新新闻
  • 免费下载软件全免费台州seo
  • 烟台网站建设-中国互联网络seo培训
  • 电脑公司网站设计移动建站模板
  • 广州国外建站模板正规接单赚佣金的app
  • 地图标注申请入口免费短视频seo排名加盟
  • 网站开发的社会背景bilibili官网网页入口
  • 帮他人做视频网站违法吗怎么开通网站平台
  • 漳州公司做网站搜索引擎的关键词优化
  • 大连 响应式网站希爱力
  • 2002年做网站多少钱抖音优化排名
  • 网站建设公司新员工培训ppt模板舆情监测系统
  • 网站地址怎么做超链接百度人工客服在哪里找
  • 厦门微网站开发网站建设报价单模板
  • asp网站后台管理系统源码网页设计用什么软件