liujx2019

Python 基础教程(第二版)笔记 (1)

P22

除非对 input 有特别的需要,否则应该尽可能使用 raw_input 函数。

长字符串,跨多行,用三个引号代替普通引号。并且不需要使用反斜线进行转义。

P23

原始字符串

print r\'c:\nowhere\'

并且不能以反斜线结尾

假如nowhere是一个文件夹,应该写成这样

print r\'c:\nowhere\' \'\\\'

P36

列表方法:1.append, 2.count, 3.extend, 4.index, 5.insert, 6.pop (唯一既修改列表又返回元素值的列表方法)

可用append和pop实现栈

P39

8.reverse, 9.sort

复制整个列表

x = [1, 2, 3]
y = x[:]

P40

高级排序:

x.sort(key=len)
x.sort(reverse=True)

P41

单个元素的元组,要加上逗号

P43

新函数表

 

分类:

技术点:

相关文章: