Python抓网页报错[Errno 22] Invalid argument

2025-05-16 09:47:04

1、在网页上抓取图片时open函数有时会报错[Errno 22] Invalid argument,如图。

Python抓网页报错[Errno 22] Invalid argument

2、然后,根据提示找到错误代码处进行查看,是open函数出了问题。

Python抓网页报错[Errno 22] Invalid argument

3、再仔细看这个部分报错的文件名称,发现有个*号,问题就找出来了。

Python抓网页报错[Errno 22] Invalid argument

4、使用.replace('*','')将*号替换,就可以了。

Python抓网页报错[Errno 22] Invalid argument

5、再次运行该代码。

Python抓网页报错[Errno 22] Invalid argument

6、最后,图片抓取完成。

Python抓网页报错[Errno 22] Invalid argument
Python抓网页报错[Errno 22] Invalid argument
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢