• 形参和实参|默认值|可选实参|tuple|*tuple|args|*args | **kwargs|args[:]|


     1 #!/usr/bin/python
     2 
     3 def hello(i,greet='long time to see!'):
     4     out =  "hello "+i+" "+greet
     5     nobody = {'as':'123','ad':'1234','om':'ssss'}
     6     if i == '2':return nobody
     7     return out
     8 
     9 name = 'we'
    10 if hello('we')==hello(name)and hello('we')==hello(i= 'we'):
    11     print "right!"
    12 
    13 #right!
    14 
    15 yoo = hello('ss','yoooo!')
    16 print yoo
    17 
    18 #hello ss yoooo!
    19 
    20 for key in hello('2','yoooo!').items():
    21     print key
    22 '''
    23 ('om', 'ssss')
    24 ('as', '123')
    25 ('ad', '1234')
    26 '''
    27 l = hello('2')
    28 print l
    29 
    30 l_1 = hello('2')
    31 l_2 = hello('2')
    32 print l_1
    33 def printnumber(**arr):
    34     for i in arr.values():
    35         print i
    36 
    37 def pr(arr):
    38     for i in arr.keys():
    39         print i
    40 
    41 
    42 printnumber(a='alala',b='bababa',c= 'sksks')
    43 pr(l_1)
    44 '''
    45 alala
    46 sksks
    47 bababa
    48 '''
    49 
    50 
    51 a = [1,2,3,4]
    52 b = ['a','b','c','d']
    53 c = [a[:],b[:]]
    54 
    55 def cut(*a_1):
    56     for i in a_1:
    57         del i[1]
    58     return a_1
    59 
    60 print cut(c[:])
    61 print a,b
    62 print cut(a[:],b[:])
    63 
    64 '''
    65 ([[1, 2, 3, 4]],)
    66 [1, 2, 3, 4] ['a', 'b', 'c', 'd']
    67 ([1, 3, 4], ['a', 'c', 'd'])
    68 '''
  • 相关阅读:
    javascript控制页面(含iframe进行页面跳转)跳转、刷新的方法汇总
    window下安装docker
    http协议
    php环境选择
    jsmooth和exe4j
    域名解析
    clientHeight,offsetHeight,scrollHeight迷一样的三个值
    LinkedHashMap和hashMap和TreeMap的区别
    fiddler抓包
    mac下配置openfire
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11132563.html
Copyright © 2020-2023  润新知