2.19学堂在线python笔记 第四课函数

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)

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

  2. python中的一切都是对象object,这意味着我们能够将特殊的函数例如对象方法和对象关联起来。
    在L4P12中你将会操纵string对象以及相关的方法

两个操纵字符串变量的命令大全
https://docs.python.org/3/library/stdtypes.html#string-methods
http://www.greenteapress.com/thinkpython/html/thinkpython009.html#toc93

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

  2. 在查找字符串命令
    str2.find('!')中,如果str2本身不含有'!'是会返回-1的值
    但是相比之下str2.index('!')则会直接报错AttributeError

  3. outstanding balance
    未清余额
    欠款

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值