以下是习题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 开始。