Lijingyang 发表于 2022-3-30 12:25:47

为什么我照着论坛上图片处理的代码抄的运行的结果还是有错然后啥也没有

这个是怎么回事,想问问

wp231957 发表于 2022-3-30 12:37:59

发文本代码及文本错误信息

Gacy 发表于 2022-3-30 13:15:28

库有了吗

Lijingyang 发表于 2022-3-30 14:27:21

Gacy 发表于 2022-3-30 13:15
库有了吗

库我安装的呢,我直接将论坛上的代码复制粘贴过来的可是不行{:5_105:}

Lijingyang 发表于 2022-3-30 14:30:06

wp231957 发表于 2022-3-30 12:37
发文本代码及文本错误信息

请输入待转换的图片名称:C:/Users/86188/Desktop/pic.png
Traceback (most recent call last):
File "C:\Users\86188\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 2957, in open
    fp.seek(0)
AttributeError: 'str' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\86188\Desktop\love.py", line 36, in <module>
    main()
File "C:\Users\86188\Desktop\love.py", line 30, in main
    texts = pic2ascii(pic, asciis, zoom, vscale)
File "C:\Users\86188\Desktop\love.py", line 4, in pic2ascii
    img = Image.open(pic)
File "C:\Users\86188\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 2959, in open
    fp = io.BytesIO(fp.read())
AttributeError: 'str' object has no attribute 'read'

小鬼 发表于 2022-3-31 14:21:23

Lijingyang 发表于 2022-3-30 14:27
库我安装的呢,我直接将论坛上的代码复制粘贴过来的可是不行

很明显是库没安装

Lijingyang 发表于 2022-3-31 22:16:48

小鬼 发表于 2022-3-31 14:21
很明显是库没安装

已经解决了,谢谢鱼油
页: [1]
查看完整版本: 为什么我照着论坛上图片处理的代码抄的运行的结果还是有错然后啥也没有