为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
python进阶_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

python进阶

廖雪峰 移动开发工程师
难度中级
时长 3小时33分
  • capitalize() 首字母大写,其余全部小写
    查看全部
  • 匿名函数有个限制,就是只能有一个表达式,不写return,返回值就是该表达式的结果。 --- Java's lambda is better than Python. Many lines can be quotes in {} blocks while using Java.
    查看全部
  • Need to read and think again.
    查看全部
    0 采集 收起 来源:python中闭包

    2018-02-20

  • 直接 return len(s.strip())>0,难道这个还不能判定空字符串吗 [最新 夕渐3509269 的回答] 因为None是没有strip和len方法的
    查看全部
  • #-*- coding: utf-8 -*- class Person(object): def __init__(self, name, score): self.name=name self.__score=score def get_grade(self): if self.__score >= 85: return 'A-优秀' else: if self.__score>=60: return 'B-及格' else: return 'C-不及格' p1 = Person('Bob', 90) p2 = Person('Alice', 65) p3 = Person('Tim', 48) print p1.get_grade() print p2.get_grade() print p3.get_grade()
    查看全部
  • 'call %s() in %fs' %(f.__name__,(t2-t1)) %s 和 %f 是占位符,输出时分别替换为 f.__name__ 和 (t2-t1)
    查看全部
  • 闭包的特点是返回的函数还引用了外层函数的局部变量,所以,要正确使用闭包,就要确保引用的局部变量在函数返回后不能变。
    查看全部
    0 采集 收起 来源:python中闭包

    2018-02-19

  • 像这种内层函数引用了外层函数的变量(参数也算变量),然后返回内层函数的情况,称为闭包(Closure)。
    查看全部
    0 采集 收起 来源:python中闭包

    2018-02-19

  • The function calculates the produce of all elements in a list. my code: ======== def calc_prod(lst): def prod(): p = 1.0 for e in lst: p *= e return p return prod f = calc_prod([1, 2, 3, 4]) print f() ======== Liao's code: ======== def calc_prod(lst): def lazy_prod(): def f(x, y): return x * y return reduce(f, lst, 1) return lazy_prod f = calc_prod([1, 2, 3, 4]) print f() ========
    查看全部
  • String objects can be compared with ">", "<" and "=". e.g. 'A' < 'B' because A's ASCII code is less B's.
    查看全部
  • What are the most used libraries? And what are the most used functions in these libraries?
    查看全部
  • kw是dict
    查看全部
  • str.upper( ) :把所有字符中的小写字母转换成大写字母 str.lower( ) :把所有字符中的大写字母转换成小写字母 str.capitalize( ) :把第一个字母转化为大写字母,其余小写 str.title( ) :把每个单词的第一个字母转化为大写,其余小写
    查看全部
  • 在Python中,函数其实也是一个对象。 f = abs f.__name__ 'abs' 由于f可以被调用,所以,f被称为可调用对象。所有的函数都是可调用对象。 一个类的实例也可以变成一个可调用对象,只需要实现一个特殊方法__call__()
    查看全部
    0 采集 收起 来源:python中 __call__

    2018-02-18

  • 如果要限制添加的属性,例如,Student类只允许添加 name、gender和score 这3个属性,就可以利用Python的一个特殊的__slots__来实现。 __slots是指一个类允许的属性列表。 __slots__ = ('name', 'gender') 子类中的__slots__不必再写父类的属性。
    查看全部
    0 采集 收起 来源:python中 __slots__

    2018-02-18

举报

0/150
提交
取消
课程须知
本课程是Python入门的后续课程 1、掌握Python编程的基础知识 2、掌握Python函数的编写 3、对面向对象编程有所了解更佳
老师告诉你能学到什么?
1、什么是函数式编程 2、Python的函数式编程特点 3、Python的模块 4、Python面向对象编程 5、Python强大的定制类
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!