美文网首页
Python3 glob

Python3 glob

作者: 水平 | 来源:发表于2016-11-07 16:01 被阅读219次

    import glob

    获取指定目录下的所有图片

    print glob.glob(r"E:/Picture//.jpg")

    获取上级目录的所有.py文件

    print glob.glob(r'../*.py') #相对路径

    父目录中的.py文件

    f = glob.iglob(r'../*.py')

    print f #<generator object iglob at 0x00B9FF80>

    for py in f:
    print py

    相关文章

      网友评论

          本文标题:Python3 glob

          本文链接:https://www.haomeiwen.com/subject/bqcouttx.html