Running a python script on all the files in a directory

前端 未结 4 704
有刺的猬
有刺的猬 2020-12-19 07:45

I have a Python script that reads through a text csv file and creates a playlist file. However I can only do one at a time, like:

python playlist.py foo.csv          


        
4条回答
  •  无人及你
    2020-12-19 08:07

    if you have directory name you can use os.listdir

    os.listdir(dirname)
    

    if you want to select only a certain type of file, e.g., only csv file you could use glob module.

提交回复
热议问题