カウンタ

COUNTER39787

日誌

Python Diary >> Article details

2019/09/02

python 備忘録

Tweet ThisSend to Facebook | by kaizen
備忘録
https://qiita.com/_yane/items/0b955a19df83dfe70b85

```python:fis.py
import os
cat = [
       os.path.join(path.fls)
       for fls in os.join.listdir(path)
       if os.path.isdir(os.path.join(path,fls))
      ]

datas = [
         [os.path.join(path,name,j),i]
         for i,name in enumerate(cat)
         for j in os.listdir(name)
        ]
```

```shell-session
$ python fis.py
Traceback (most recent call last):
  File "fis.py", line 4, in <module>
    for fls in os.join.listdir(path)
AttributeError: module 'os' has no attribute 'join'
```


【Python入門】便利!joinの使い方まとめ
https://www.sejuku.net/blog/41752


```
import os
cat = [
       os.path.join(path.fls)
       for fls in os.path.join.listdir(path)
       if os.path.isdir(os.path.join(path,fls))
      ]

datas = [
         [os.path.join(path,name,j),i]
         for i,name in enumerate(cat)
         for j in os.listdir(name)
        ]
```

```
$ python fis.py
Traceback (most recent call last):
  File "fis.py", line 4, in <module>
    for fls in os.path.join.listdir(path)
AttributeError: 'function' object has no attribute 'listdir'
```

AttributeError: 'function' object has no attribute 'plt' のエラー
https://teratail.com/questions/74675

```
import os
cat = [
       os.path.join(path.fls)
       for fls in os.path.join().listdir(path)
       if os.path.isdir(os.path.join(path,fls))
      ]

datas = [
         [os.path.join(path,name,j),i]
         for i,name in enumerate(cat)
         for j in os.listdir(name)
        ]
```

$ python fis.py
Traceback (most recent call last):
  File "fis.py", line 4, in <module>
    for fls in os.path.join().listdir(path)
TypeError: join() missing 1 required positional argument: 'a'


【Python入門】listdir関数でデータを取得する方法

https://qiita.com/Morio/items/f34dab8825c9d76664f5

import os
cat = [
       os.path.join(path.fls)
       for fls in os.path.listdir(path)
       if os.path.isdir(os.path.join(path,fls))
      ]

datas = [
         [os.path.join(path,name,j),i]
         for i,name in enumerate(cat)
         for j in os.listdir(name)
        ]

$ python fis.py
Traceback (most recent call last):
  File "fis.py", line 4, in <module>
    for fls in os.path.listdir(path)
AttributeError: module 'posixpath' has no attribute 'listdir'    


12:53 | Impressed! | Voted(0) | Comment(0)