How to traverse through the files in a directory?

前端 未结 9 1764
离开以前
离开以前 2020-11-30 11:34

I have a directory logfiles. I want to process each file inside this directory using a Python script.

for file in directory:
      # do something
         


        
9条回答
  •  醉酒成梦
    2020-11-30 11:55

    With os.listdir() or os.walk(), depending on whether you want to do it recursively.

提交回复
热议问题