JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

RuntimeError: dictionary changed size during iteration

发布时间 2023-10-09 17:20:27作者: 你说夕阳很美

RuntimeError: dictionary changed size during iteration 解决办法-CSDN博客

字典遍历时,不允许修改

修改前

    for key in sys.modules.keys():
        if key.startswith('selenium'):
            del sys.modules[key]

改成list

    for key in list(sys.modules.keys()):
        if key.startswith('selenium'):
            del sys.modules[key]

 

    本栏目推荐文章
  • C#中的List<T>和Dictionary<TKey, TValue>的底层原理
  • Objectarx system dictionary
  • Dictionary原理(转)
  • 【C#】中Dictionary的用法总结
  • pytorch反向传播错误解决:RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
  • Iterator集合底层原理
  • 基于源码去理解Iterator迭代器的Fail-Fast与Fail-Safe机制
  • CF396C On Changing Tree 题解
  • jumpserver连接ecs实例报错:UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh_exchange_identification: Connection closed by remote host", "unreachable": true
  • ssh WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 解决办法
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们