Error while using listdir in Python

后端 未结 8 934
小蘑菇
小蘑菇 2020-12-10 04:14

I\'m trying to get the list of files in a particular directory and count the number of files in the directory. I always get the following error:

WindowsError         


        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 04:56

    Two things:

    1. os.listdir() does not do a glob pattern matching, use the glob module for that
    2. probably you do not have a directory called '/client_side/*.*', but maybe one without the . in the name

    The syntax you used works fine, if the directory you look for exists, but there is no directory called '/client_side/.'.

    In addition, be careful if using Python 2.x and os.listdir, as the results on windows are different when you use u'/client_side/' and just '/client_side'.

提交回复
热议问题