博客
关于我
python学习day11(集合,常见方法)
阅读量:396 次
发布时间:2019-03-04

本文共 707 字,大约阅读时间需要 2 分钟。

????

??????Python??????????????????????????????????????????

???????

?? {} ? set() ??????

  • s1 = {10, 20, 30, 40, 50}

    • ?????{10, 20, 30, 40, 50}
  • s2 = {10, 20, 30, 40, 10, 20}

    • ?????{10, 20, 30, 40}
  • s3 = set('abdbsdf')

    • ?????{'a', 'b', 'd', 'f', 's', 's'}?????
  • s4 = set()

    • ?????<class 'set'>

?????

????

  • add()???????

    s1 = {10, 20, 30, 40, 50}s1.add(100)
    • ???{10, 20, 30, 40, 50, 100}
  • add()????None

    s1.add(10)
    • ???None
  • update()???????

    s2 = [10, 20, 30, 40, 10, 20]s1.update(s2)
    • ???{10, 20, 30, 40}

????

  • remove()??????????????

    s1.remove(10)
    • ???{20, 30, 40, 50}
  • discard()???????????????

    s1.discard(10)
    • ???{20, 30, 40, 50}
  • pop()??????????

    s1.pop()
    • ????40

????

  • in???????

    10 in s1
    • ???True
  • not in????????

    10 not in s1
    • ???True

转载地址:http://msfg.baihongyu.com/

你可能感兴趣的文章
Nginx 反向代理解决跨域问题
查看>>
Nginx 反向代理配置去除前缀
查看>>
nginx 后端获取真实ip
查看>>
Nginx 学习总结(16)—— 动静分离、压缩、缓存、黑白名单、性能等内容温习
查看>>
Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
nginx+Tomcat性能监控
查看>>
Nginx下配置codeigniter框架方法
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
查看>>
nginx添加模块与https支持
查看>>