(2.19学堂在线python笔记)

@[TOC](2.19学堂在线python笔记)

1. Boolean Operations — and, or, not¶

These are the Boolean operations, ordered by ascending priority:

Operation Result Notes

x or y if x is false, then y, else x (1)

x and y if x is false, then x, else y (2)

not x if x is false, then True, else False (3)

Notes:

This is a short-circuit operator, so it only evaluates the second argument if the first one is false.

This is a short-circuit operator, so it only evaluates the second argument if the first one is true.

not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.

这里对几个逻辑表达式的解释比较有意思,例如(1)当x是假的时候,仅计算y.当x是真的时候返回真

(2)当x是真的时候,仅计算y.当x是假的时候返回假

(3)not比非布尔型变量等级更低,所以

    not a == b  等价于 not(a==b)

2. `str.lower()`命令能够把大写字符转化成小写,更多详见http://www.runoob.com/python3/python3-upper-lower.html

3. python中的一切都是对象object,这意味着我们能够将特殊的函数例如对象方法和对象关联起来。

在L4P12中你将会操纵string对象以及相关的方法

两个操纵字符串变量的命令大全

https://docs.python.org/3/library/stdtypes.html#string-methods

http://www.greenteapress.com/thinkpython/html/thinkpython009.html#toc93

4. 字符串本身是没办法改变的,你使用函数只能得到一个新的字符串

5. 在查找字符串命令

`str2.find('!')`中,如果`str2`本身不含有`'!'`是会返回-1的值

但是相比之下`str2.index('!')`则会直接报错AttributeError

6. outstanding balance

未清余额

欠款

你可能感兴趣的:((2.19学堂在线python笔记))