os.path.isfile() doesn't work. Why?

后端 未结 2 1917
不知归路
不知归路 2020-12-07 03:42

I\'m trying to do this:

import os
[x for x in os.listdir(\'.\') if os.path.isfile(x)]
[x for x in os.listdir(\'dirname\') if os.path.isfile(x)]
[x for x in o         


        
2条回答
  •  时光说笑
    2020-12-07 04:34

    isfile() is looking in the current directory. Unless you include the directory name with the file name it has no idea where to find your files.

提交回复
热议问题