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 !
  • 相关阅读:
    Istio安装配置及使用
    Istio介绍
    Rancher管理k8s集群
    EFK部署
    常见日志收集方案及相关组件
    Prometheus Pushgateway
    Prometheus监控拓展
    Prometheus PromQL语法
    开始新工作了
    SpringBlade 新系统 运行
  • 原文地址:https://www.cnblogs.com/maxiaohei/p/7797842.html
Copyright © 2011-2022 走看看