
[code]

    import glob
    from PIL import Image
    
        コードをここに入力
        image_paths = glob.glob('test_data/test/' + "*.jpg")
        image_paths = [image_paths]
    
        for i in image_paths:
            img = Image.open(i)
    
[/code]

[code]

    AttributeError                            Traceback (most recent call last)
    File /opt/anaconda3/lib/python3.9/site-packages/PIL/Image.py:2957, in open(fp, mode, formats)
       2956 try:
    -> 2957     fp.seek(0)
       2958 except (AttributeError, io.UnsupportedOperation):
    
    AttributeError: 'list' object has no attribute 'seek'
    
    During handling of the above exception, another exception occurred:
    
    AttributeError                            Traceback (most recent call last)
    Input In [28], in <cell line: 1>()
          1 for i in image_paths:
    ----> 2     img = Image.open(i)
    
    File /opt/anaconda3/lib/python3.9/site-packages/PIL/Image.py:2959, in open(fp, mode, formats)
       2957     fp.seek(0)
       2958 except (AttributeError, io.UnsupportedOperation):
    -> 2959     fp = io.BytesIO(fp.read())
       2960     exclusive_fp = True
       2962 prefix = fp.read(16)
    
    AttributeError: 'list' object has no attribute 'read'
    
[/code]


CC BY-SA 4.0
2022-07-06T16:30:12.450
89794
2022-07-06T17:09:00.130
2022-07-06T16:31:59.727
3060
20860
question
python
for文を使って画像を連続表示させたい


`image_paths = [image_paths]`の行を削除すれば動作が継続して状況が変化するでしょう。

その前の行の`image_paths = glob.glob('test_data/test/' +
"*.jpg")`の結果がリストで通知されるので、`image_paths =
[image_paths]`を行うと`image_paths`の内容がリストのリストになるため、質問のエラーが発生すると考えられます。

提示されたソースコードには表示する処理は書かれていないので単に時間が経過して終了するだけかもしれませんが。


CC BY-SA 4.0
2022-07-06T17:09:00.130
89795
2022-07-06T17:09:00.130
26370
89794
answer