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

初识Python

廖雪峰 移动开发工程师
难度入门
时长 5小时 0分
  • print L[0:10]#表示从物理位置0开始到9结束,共10个数字。不包括索引是10的数字 print L[2::3]#表示从L[2]开始,结束位置不确定,但是每个3个数取一次 print L[4:51:5]#表示从L[4]开始取值,结束位置L[50],不包括L[51],每个5个数取一次
    查看全部
    0 采集 收起 来源:对list进行切片

    2017-03-28

  • 下载notepad++
    查看全部
  • for和if后边都要加:
    查看全部
    0 采集 收起 来源:Python之 for循环

    2017-03-28

  • python
    查看全部
  • if : elseif else:
    查看全部
    0 采集 收起 来源:Python之if语句

    2017-03-28

  • 包括领域
    查看全部
  • tuple ——指向不变
    查看全部
  • python HTML table: d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 } def generate_tr(name, score): if score < 60: return '<tr><td>%s</td><td >%s</td></tr>' % (name, score) return '<tr><td>%s</td><td>%s</td></tr>' % (name, score) tds = [generate_tr(name, score) for name, score in d.iteritems()] print '<table border="1">' print '<tr><th>Name</th><th>Score</th><tr>' print '\n'.join(tds) print '</table>'
    查看全部
    0 采集 收起 来源:复杂表达式

    2018-03-22

  • 看大家的笔记,获益匪浅 t = ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ) print t t= tuple(x for x in range(0,10)) print t t = tuple(range(0,10)) print t print tuple(range(0,10)) print tuple(range(10)) print list(range(0,10))
    查看全部
  • ;C:\Python27
    查看全部
  • L[0],L[1] = L[1],L[0] 即可以将两个元素互换 list.append(x)——在末尾插入 list.insert(index,x)——在索引值index处插入 list.pop(index)——删除 互换
    查看全部
  • 在Python程序中,变量是用一个变量名表示,变量名必须是大小写英文、数字和下划线(_)的组合,且不能用数字开头
    查看全部
  • L = ['Adam', 'Lisa', 'Paul', 'Bart'] L.pop(2) L.pop() print L 运行结果: ['Adam', 'Lisa'] 分析原因: Paul的索引是2,Bart的索引是3,如果我们要把Paul和Bart都删掉,请解释下面的代码为什么不能正确运行: L.pop(2) L.pop(3) 因为执行了L.pop(2)后Paul删掉了,这是在L中的Bart作为list列表的最后一个元素同时其索引为2.要删掉Bart可以用L.pop()或者L.pop(2)
    查看全部
  • a = 'python' print 'hello,', a or 'world' b = '' print 'hello,', b or 'world' 运行结果: hello, python hello, world 分析: 两条输出语句重点在于分析or运算。在python解释器中做布尔运算时,只要能提前确定计算结果,它就不会往后算,直接返回结果。 print 'hello,', a or 'world'==>由于a是非空字符串则a是True,根据或运算法则,整个计算结果必为True,直接返回a==>因此输出hello,python print 'hello,', b or 'world'==>由于b是空字符串则a是False,根据或运算法则,整个计算结果必定取决于后面的'world',直接返回'world'==>因此输出hello,world
    查看全部
  • print 'hello, python' print 'hello,','python' print 'hello,'+'python' print 'hello,python' 输出结果: hello, python hello, python hello,python hello,python 前两行可以再字符串里输空格,也可在两个字符串间输个单引号","来达到字母间的缩进 后两行"+"起连接作用,字母间没有空格
    查看全部

举报

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

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