笨办法学python的笔记之一

以下是习题18之前的零散笔记
  • doc下退出python:quit()
  • py2里的raw_input,到py3里,变成input
  • Windows 下是 CTRL-Z 来关闭编译器

以下是部分习题的汇总笔记
  • ex18:
    run,call,use 是同一个意思
  • ex20:
    seek(): file.seek(off, whence=0):从文件中移动off个操作标记(文件指针),正往结束方向移动,负往开始方向移动。如果设定了whence参数,就以whence设定的起始位为准,0代表从头开始,1代表当前位置,2代表文件最末尾位置。原文链接

    更多seek()解释如下:原文链接

    <span style="font-size:10px;">if you want to read the whole file but skip the first 20 bytes, open the file, seek(20) to move to where you want to start reading, then continue with reading the file.
    Or say you want to read every 10th byte, you could write a loop that does seek(9, 1) (moves 9 bytes forward relative to the current positions), reads one byte, repeat.</span>


  • <span style="font-size:10px;">ex25:
    试着执行 help(ex25) 和 help(ex25.break_words) 。这是你得到模组帮助文档的方式。 所谓帮助文档就是你定义函数时放在 """ 之间的东西,它们也被称作 documentation comments (文档注解)</span>
  • ex32: class list([iterable])

    Lists may be constructed in several ways:

    • Using a pair of square brackets to denote the empty list[]
    • Using square brackets, separating items with commas: [a][a, b, c]
    • Using a list comprehension: [x for x in iterable]
    • Using the type constructor: list() or list(iterable)

  • ex33:
    碰到程序跑着停不下来了,这时你只要按着 CTRL 再敲 c (CTRL-c),这样程序就会中断下来了。

  • ex34:
    记住: ordinal == 有序,以 1 开始;cardinal == 随机选取, 以 0 开始。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值