zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    signal, sigaction,信号集合操作
    how to create view (windows)
    设计模式-单例模式
    clearcase command (windows 常用的几个)
    struts2提交文件时,出现页面重置又无法返回input现象,我没有解决这个问题
    报错如HTTP Status 404
    srm开发(基于ssh)(3)
    报错HTTP Status 500
    编写程序时候莫名出现<property name="dialect">org.hibernate.dialect.FirebirdDialect</property>
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is
  • 原文地址:https://www.cnblogs.com/alansuny/p/12491122.html
Copyright © 2011-2022 走看看