zoukankan      html  css  js  c++  java
  • 文件打开编辑和函数参数

    #f = open("yesterday2",'r+',encoding="utf-8") #文件句柄 读写
    #f = open("yesterday2",'w+',encoding="utf-8") #文件句柄 写读
    #f = open("yesterday2",'a+',encoding="utf-8") #文件句柄 追加读写
    f = open("yesterday2",'wb') #文件句柄 二进制文件

    函数传参:
    #*args:接受N个位置参数,转换成元组形式
    # def test(*args):
    # print(args)
    #
    # test(1,2,3,4,5,5)
    # test(*[1,2,4,5,5])# args=tuple([1,2,3,4,5])

    # def test1(x,*args):
    # print(x)
    # print(args)
    #
    # test1(1,2,3,4,5,6,7)


    #**kwargs:接受N个关键字参数,转换成字典的方式
    # def test2(**kwargs):
    # print(kwargs)
    # print(kwargs['name'])
    # print(kwargs['age'])
    # print(kwargs['sex'])
    #
    # test2(name='alex',age=8,sex='F')
    # test2(**{'name':'alex','age':8})
    # def test3(name,**kwargs):
    # print(name)
    # print(kwargs)
    #
    # test3('alex',age=18,sex='m')

    # def test4(name,age=18,**kwargs):
    # print(name)
    # print(age)
    # print(kwargs)
    #
    # test4('alex',age=34,sex='m',hobby='tesla')

    def test4(name,age=18,*args,**kwargs):
    print(name)
    print(age)
    print(args)
    print(kwargs)
    logger("TEST4")

    def logger(source):
    print("from %s" % source)

    test4('alex',age=34,sex='m',hobby='tesla')

  • 相关阅读:
    ZOJ2913Bus Pass(BFS+set)
    HDU1242 Rescue(BFS+优先队列)
    转(havel 算法)
    ZOJ3761(并查集+树的遍历)
    ZOJ3578(Matrix)
    HDU1505
    ZOJ3574(归并排序求逆数对)
    VUE-脚手架搭建
    VUE脚手架搭建
    VUE-node.js
  • 原文地址:https://www.cnblogs.com/smlie/p/8167713.html
Copyright © 2011-2022 走看看