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

初识Python

廖雪峰 移动开发工程师
难度入门
时长 5小时 0分
  • set: series of elements are arranged in set which are disorder. these elements repeated is deleted from set. s = set([list]); L = [1, 2, 2, 3]; s = ([1, 2, 3])
    查看全部
  • 1.对于很大或很小的浮点数,就必须用科学计数法表示,把10用e替代,1.23x10^9就是1.23e9,或者12.3e8,0.000012可以写成1.2e-5,等等。浮点数运算则可能会有四舍五入的误差。 2.python的空值不是用NULL而是None来表示,None不能理解为0,因为0是有意义的,而None是一个特殊的空值。
    查看全部
  • d['addition'] = value; 1. key exists in d: the elder value is replaced by the new one; 2. key is new: add new value such that key - value.
    查看全部
    0 采集 收起 来源:Python更新dict

    2016-09-23

  • The seeking rate of dict is much faster than that of list, while it takes larger internal storage. the 'keys' in dict are different with each other, and they are unchangeable. the 'key - values' in dict are disorder so that dict cant be used to store ordered set.
    查看全部
  • print d['Adam']; print d.get('paul'); if 'Paul' in d: print d['Paul']
    查看全部
    0 采集 收起 来源:Python之访问dict

    2016-09-23

  • unicode使得二字节表示,要输出中文需加u
    查看全部
  • 1. 0 - 100; ======> if x > 100: break 2. x is even number; ==========> if x % 2 == 0: continue
    查看全部
  • tr代表一行 以<tr>开始,</tr>结束 td代表一格 以<td>开始,</td>介绍 中间的style就是颜色了 <tr><td>%s</td><td >%s</td></tr>就代表有一行,有2个格子,第二个格子用红色显示!
    查看全部
    1 采集 收起 来源:复杂表达式

    2018-03-22

  • dict的第一个特点是查找速度快,无论dict有10个元素还是10万个元素,查找速度都一样。而list的查找速度随着元素增加而逐渐下降。 不过dict的查找速度快不是没有代价的,dict的缺点是占用内存大,还会浪费很多内容,list正好相反,占用内存小,但是查找速度慢
    查看全部
  • 函数记得要有return
    查看全部
  • tds = ['<tr><td>%s</td><td>%s</td></tr>' % (name, score) for name, score in d.iteritems()] print '<table>' print '<tr><th>Name</th><th>Score</th><tr>' print '\n'.join(tds) print '</table>'
    查看全部
    0 采集 收起 来源:复杂表达式

    2018-03-22

  • 迭代dict的key和value 1、dict.items() 2、dict.iteritems() iteritems() 不把dict转换成list,而是在迭代过程中不断给出 tuple,所以, iteritems() 不占用额外的内存
    查看全部
  • dict 对象有一个 values() 方法,这个方法把dict转换成一个包含所有value的list,这样,我们迭代的就是 dict的每一个 value dict除了values()方法外,还有一个 itervalues() 方法 1. values() 方法实际上把一个 dict 转换成了包含 value 的list。 2. 但是 itervalues() 方法不会转换,它会在迭代过程中依次从 dict 中取出 value,所以 itervalues() 方法比 values() 方法节省了生成 list 所需的内存。
    查看全部
    0 采集 收起 来源:迭代dict的value

    2016-09-23

  • 使用 enumerate() 函数,我们可以在for循环中同时绑定索引index和元素name: for index, name in enumerate(L): ... print index, '-', name zip()函数可以把两个 list 变成一个 list
    查看全部
    0 采集 收起 来源:索引迭代

    2016-09-23

  • 集合是指包含一组元素的数据结构,我们已经介绍的包括: 1. 有序集合:list,tuple,str和unicode; 2. 无序集合:set 3. 无序集合并且具有 key-value 对:dict
    查看全部
    0 采集 收起 来源:什么是迭代

    2016-09-22

举报

0/150
提交
取消
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作。
友情提示:

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