ignore the hidden files in python

import os

root = "/Users/Siddhartha/Desktop/py scripts"
for item in os.listdir(root):
    if not item.startswith('.') and os.path.isfile(os.path.join(root, item)):
        print item
        

Reference:
[1] https://stackoverflow.com/questions/15235823/how-to-ignore-hidden-files-in-python-functions

posted @ 2023-03-24 08:27  xiaoxuxli  阅读(12)  评论(0编辑  收藏  举报