TypeError: 'NoneType' object is not iterable

源码

def get_url(lines):

    urls=[]
for line in lines:
if 'img' in urls:
url=line.split('src=')[-1].split('"')[1]
urls.append(url) def outputto(urls):
count=0
for line in urls:
print('第{:2}个url为{}'.format(count,line))
count=count+1

意思是urls里面的内容为空

向上找发现 上面的get_url 函数未添加return 返回值

需要在下面的函数调用,所以返回报错

运行后在for line in urls 报错

TypeError: 'NoneType' object is not iterable 一次错误场景的更多相关文章

  1. python TypeError: 'NoneType' object is not iterable

    list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > ...

  2. python"TypeError: 'NoneType' object is not iterable"错误解析

    尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...

  3. append导致TypeError: 'NoneType' object is not iterable

    a=[1,2,3] a.append(4) a Out[4]: [1, 2, 3, 4] a=a.append(5) print(a) None a =[1,2,3] print(a.append(4 ...

  4. 'NoneType' object is not iterable

    "TypeError: 'NoneType' object is not iterable" 一般是返回值为None同时赋值给了多个变量

  5. Python问题:'Nonetype' object is not iterable

    参考链接:http://blog.csdn.net/dataspark/article/details/9953225 [解析] 这个错误提示一般发生在将None赋给多个值时. [案例] 定义了如下的 ...

  6. TypeError: 'NoneType' object is not subscriptable

    运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了

  7. TypeError: 'ExcelData' object is not iterable

    今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...

  8. TypeError: 'TestCase' object is not iterable

    这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...

  9. python报错Nonetype object is not iterable

    https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/detail ...

  10. Python : TypeError: 'int' object is not iterable

    用循环依次对list中的每个名字打印出 Hello, xxx! -------------------------------------------------------- L = ['Bart' ...

随机推荐

  1. JunitGenerator

    ######################################################################################## ## ## Avail ...

  2. Qt编写地图综合应用29-迁徙图

    一.前言 迁徙图和上一篇的闪烁点图类似,也需要提供三个基本要素:城市名称集合.城市经纬度集合.中心点城市经纬度,至于城市点的颜色和迁徙流向箭头的颜色,都可以单独设置,echart对每个类对象都竭尽全力 ...

  3. Qt开源作品41-网络调试助手增强版V2022

    一.前言 做网络通信少不了网络收发数据,经常用到网络数据的调试相关工具,以便侦听数据用来判断数据是否正确,许久以前就发布过类似的工具,第一版大概在2013年,第二版大概在2017年,中间参考过不少的网 ...

  4. error LNK2038: 检测到“_MSC_VER”的不匹配项问题

    _MSC_VER这个相当于做了宏的检测 _MSC_VER 定义编译器的版本. 一些编译器版本的_MSC_VER值:MS VC++ 14.0 _MSC_VER = 1900 vs2015MS VC++ ...

  5. PHP 安装启用openssl(解决 wordpress可选的模组openssl未被安装或已被禁用)

    本教程仅适用Windows Servier IIS网站服务器. 我的博客使用IIS搭建,相比Linux,相关的教程格外少.因此让以后的小伙伴也能马上解决问题,分享此方法. 首先需要下载php对应版本的 ...

  6. 【Java并发编程线程池】 ForkJoinPool 线程池是什么 怎么工作的 和传统的ThreadPoolExecutor比较

    Java 中的 ForkJoinPool 线程池是什么 怎么工作的 Java 中的 ForkJoinPool 线程池是什么 怎么工作的 相比较于传统的线程池,ForkJoinPool 线程池更适合处理 ...

  7. 深入解析子查询(SUBQUERY):增强 SQL 查询灵活性的强大工具

    title: 深入解析子查询(SUBQUERY):增强 SQL 查询灵活性的强大工具 date: 2025/1/12 updated: 2025/1/12 author: cmdragon excer ...

  8. UWP ManipulationStarted 移动图片或控件不要滑出父容器的判断

    假设自定义一个用户控件用以在父容器Grid里拖动/移动: <UserControl x:Class="App6.Pic" xmlns="http://schemas ...

  9. WPF 透明背景窗体

    <Window x:Class="WpfApplication8.MainWindow" xmlns="http://schemas.microsoft.com/w ...

  10. idea创建一个入门Spring Boot项目(controller层)使用Maven代码管理

    springboot的优质开发体验,能够更快速的搭建生产环境的项目.这篇文章就是一个超级简单的入门springboot项目.包含了一些简单的理论和超简单Controller层 [工具] IDEA 全称 ...