2020年12月23日星期三

Strange behavior os.path.isdir(x)

I want to get dir list of current dir only (no recursion).

Also, I have mount point /mnt/test0 with ext4.

I do:

>>> [x for x in os.listdir('/mnt/test0/base/trash') if os.path.isdir(x)]  []  

/mnt/test0/base/trash has one dir test, however list is empty.

If I do:

>>> [x for x in os.listdir('/mnt/test0/base/trash')]  

It's here.

>>> [x for x in os.listdir('/mnt/test0/base/trash')]  ['test']  

Linux ls:

# ls -lA  total 28  drwxrwx--- 9 root root 28672 Nov 11 23:00 test  

What is the strange bug of os.path.isdir(x)?

https://stackoverflow.com/questions/65432769/strange-behavior-os-path-isdirx December 24, 2020 at 09:03AM

没有评论:

发表评论