zoukankan      html  css  js  c++  java
  • 循环获取文件名,拼接路径打印

    import os   

        # os.getcwd() 返回一个表示当前工作目录的字符串
    # os.listdir()函数,它的作 用是返回一个参数所指定目录的所有文件名字符串的列表
       # os.sep 获取系统分隔符
    import os

    try:
    print(os.getcwd())
    # os.getcwd() 返回一个表示当前工作目录的字符串
    # os.listdir()函数,它的作 用是返回一个参数所指定目录的所有文件名字符串的列表
    filenames = os.listdir(os.getcwd())
    for name in filenames:
    print(os.getcwd()+os.sep+name)
    except Exception as e:
    print(e)

    结果实例:

    G:学习hello-vue-django-masterhello-vue-django-master   #  os.getpwd()
    G:学习hello-vue-django-masterhello-vue-django-master.babelrc
    G:学习hello-vue-django-masterhello-vue-django-master.eslintrc.js
    G:学习hello-vue-django-masterhello-vue-django-mastermanage
    G:学习hello-vue-django-masterhello-vue-django-master ames.txt
    LESS IS MORE !
  • 相关阅读:
    串口应用
    状态栏颜色
    冒泡排序
    快速排序
    good软件测试博客地址
    软件测试面试题
    股票基础知识
    软件测试基本知识
    软件测试流程
    mycat实现分库分表(二)
  • 原文地址:https://www.cnblogs.com/maxiaohei/p/7797842.html
Copyright © 2011-2022 走看看