博客
关于我
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/

你可能感兴趣的文章
php--防止sql注入的方法
查看>>
PHP-CGI Windows平台远程代码执行漏洞复现(CVE-2024-4577)
查看>>
php-cgi耗尽报502错误
查看>>
php-cgi(fpm-cgi) 进程 CPU 100% 与 file_get_content...
查看>>
PHP-DI/Invoker 开源项目使用教程
查看>>
php-fpm与Nginx运行常见错误说明
查看>>
php-fpm比php成为apache模块好在哪
查看>>
php-fpm超时时间设置request_terminate_timeout分析
查看>>
PHP-GD库-分类整理
查看>>
php-laravel框架用户验证(Auth)模块解析(一)
查看>>
php-laravel框架用户验证(Auth)模块解析(三)登录模块
查看>>
php-laravel框架用户验证(Auth)模块解析(二)注册模块
查看>>
php-laravel框架用户验证(Auth)模块解析(四)忘记密码
查看>>
php-redis中文参考手册_Ping_echo_set_get_setex_psetex_...
查看>>
PHP-Shopify-API-Wrapper 使用教程
查看>>
php-兔子问题,斐波那契数列
查看>>
PHP-希尔排序
查看>>
php-数据结构-二叉树的构建、前序遍历,中序遍历,后序遍历,查找,打印
查看>>
php-有序数组合并后仍有序
查看>>
redis使用
查看>>