📜  python for file in dir - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:30.597000             🧑  作者: Mango

代码示例4
## Using scandir
import os

directory = r'C:\Users\admin'
for entry in os.scandir(directory):
    if (entry.path.endswith(".jpg")
            or entry.path.endswith(".png")) and entry.is_file():
        print(entry.path)