Mac 下 Python os.listdir 出现 invalid literal for int() with base 10 错误

因为 Mac 下的 .DS_Store 也会包含进去

解决方法:

def listdirInMac(path):
    os_list = os.listdir(path)
    for item in os_list:
        if item.startswith('.') and os.path.isfile(os.path.join(path, item)):
            os_list.remove(item)
    return os_list

 

posted @ 2016-03-16 00:13  藥師  阅读(1683)  评论(0编辑  收藏  举报