• python:practice set copy


    content will be learn:

    how to use set.

    set is a object ,characters :not be repetitive,can be hashing.

    startup in two way :

    set () can be add and delete

    frozenset()  can not be change,not be update and remove

    set () :use to intersection,union set ,aperation to achieve our goal

    a=set('suny)

    a.add('go‘)。old set ,have four elements:'s','u','n','y'

                           renew set :have five elements:'s','u;,'n','y','go'

    a.update('go').old set  hvae four elements:'s',;u;,'n;,;y;

                           renew set have six elements:'s;'u','n','y','g','o'

    remove,del  

    set() operation characters:

    in ,not in  == != :return Boole value 'True' 'False'

    ,subset (subaggregate subcollection)superset: can use to remove duplicates.de-weight.

    calling set () :

    for i in set():

    print(i)

    subset(subaggregate,subcollection),operation characters

    set()>set()

    set() in set()

    combin two more set().can use operate union() or  

    union and or is equivalent.

    operation characters:

    set() | set()

    s1.union(s2)

    intersection:

    operation characters:

    set()&set()

    s1 . intersection(s2)

    check set :

    operation characters:

    difference

    s3=s1-s2

    s1 . difference(s2)

    symmetric difference set()

    operation characters:

    s3=s1^s2

    s1 . symmetric.difference(se)

    subroutine,subaggregate

    function parameters:

    category:

    form parameters; for example.   def     function(a,). this way  'a' is a form parameters.

    actual parameters(actual argument):   function(1,2).this '1,2' is actual parameters.

    default parameters:   instance:  def  function( sexuality='male')  this 'sexuality' is default.

    uncertain parameters:   def function (*args)  this ' *args' is uncertain parameters.

                                                                      can be  assignment(evaluation,valuation)

    *args can be assignment unnamed parameters  or untitled parameters. for example  19  'male'

    def function (*args)

    a=[1,2,3]

    function(a) express for ([1,2,3],)

    function(*a) express for (1,2,3)

    if function (*[1,2,3} show for [1,2,3] same  to function assignment list

    **args can be assignment named parameters.or titled parameters. for example  name=' alan'

    def function(**kwargs):

    a={}

    function(**a) can express for {   }

    placeholder:

    placeholder characters: %s   usage:  print(' you can go to %s'% parameters)

                                                                                                     the position have many parameters can express as " go to  %s,%s"%(parameter,parameter)

    formal parameters and actual parameters corresponding relation:  one position  formal parameter  corresponding  one actual parameter.

  • 相关阅读:
    感悟
    shadow classification
    interpolation
    c语言调试技巧
    注册博客园
    用jQuery实现图片预加载和等比例缩小,大图可以点击关闭
    焦点图,带数字显示,支持常见浏览器
    又一个jquery轮播效果,焦点图,带数字显示序号,这个可以添加对应标题在图片上,支持主流浏览器
    纯css下拉菜单,支持CSS3圆角
    Jquery 下拉菜单,可以设置颜色,支持CSS3圆角
  • 原文地址:https://www.cnblogs.com/alansuny/p/12491122.html
Copyright © 2020-2023  润新知