• 集合1


    什么是集合:由不同的元素组成,集合中的元素排列无序,集合必 须是不可变类型(数字,字符串)

    集合的创建:

    s = {'hello','world','python','python','jalor'} #集合,输出时会进行去重,因为为不同元素
    drict = {s:'hello',m:'max',y:'yellow'}#字典

    type的作用:type类型转换

    利用set函数直接定义集合

    s = set('hello')
    print (s) 
    {'h','o','l','e'}
    ####
    s = set(['hello','hello','world'])
    print (s)
    >>{'hello','world'}
    #集合中的内置方法 add(),clear(),copy(),pop()随机删除,remove(self,x)指定删除,discard()也是制定删除但不会报错
  • 相关阅读:
    Codeforces 1072
    XDOJ 1046
    BZOJ 1002
    BZOJ 1001
    BZOJ 1500/Luogu 2042
    nowcoder 211B
    BZOJ 3224
    BZOJ 1150
    POJ 2442
    二叉堆和二叉搜索树进阶
  • 原文地址:https://www.cnblogs.com/LittleGreenOrc/p/9490537.html
Copyright © 2020-2023  润新知