zoukankan      html  css  js  c++  java
  • Python和java 的区别笔记(未完成)

    1.  非  boolean not

    Python     not 

    java           !

     2.函数中的缺省值

    如果函数中有一个值是 常用的例如下图的 score  合格分数线

    def  overScoreStudents(studentScoreList, score):
        count = 0
    
        # 下面的代码用到了循环和判断,后面章节会学习到
        for ss in studentScoreList:
            if ss >= score:
                count += 1
        
        return count

    那么可以写为

    def  overScoreStudents(studentScoreList, score=60):

    那么 如果没有定于score时 ,直接  overScoreStudents(ssList)  此时score默认为60

    如果需要定义时 overScoreStudents(ssList, 70) 此时score为70

    注意:arg4 前面的参数 arg3 已经有缺省值,所以必须也要有缺省值,比如

    def  func(arg1, arg2, arg3=3, arg4='hello'):

    指定参数名调用函数

    这样的一个函数

    def  func(arg1, arg2, arg3=3, arg4='hello'):
        print(arg1)
        print(arg2)
        print(arg3)
        print(arg4)
    

    我们调用的时候,可以这样

    func(1,2,3,'hello')

    也可以这样 指定参数名 去调用

    func(arg1=1,arg2=2,arg3=3,arg4='hello')

    指定参数名调用的时候,可以颠倒参数的次序

    func(arg2=1,arg3=2,arg1=3,arg4='hello')

    也可以这样混合使用

    func( 1, 2, arg3=3,arg4='hello')
    


    但是一旦某个参数指定了参数名,后面所有的参数必须指定参数名

    像下面这样是不可以的

    func( 1, 2, arg3=3, 'hello') # 错误的调用方式
  • 相关阅读:
    sqlserver监控体系
    使SQL用户只能看到自己拥有权限的库
    存储过程版本控制-DDL触发器
    查看剩余执行时间
    迁移数据库文件位置
    sublime使用Package Control不能正常使用的解决办法
    未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序的处理方式
    1770Special Experiment
    1848Tree
    1322Chocolate
  • 原文地址:https://www.cnblogs.com/goodgoodstudy2018/p/13947673.html
Copyright © 2011-2022 走看看