运算符
# x or y 如果 x 为真,则值为x,否则为y 1 print(4 or 3) # 4
2 print(2 or 3) # 2
3 print(1 or 3) # 1
4 print(0 or 3) # 3
5 print(-1 or 3) # -1 # x and y 如果 x 为真,则a值为y,否则为x
1 print(4 and 3) # 3
2 print(2 and 3) # 3
3 print(1 and 3) # 3
4 print(0 and 3) # 0
5 print(-1 and 3) # 3
# or前面x如果是数字(并且x为真)则x返回数字。前面x是比较,则x返回真假布尔值。
1 print(3 or 3>2) # 3
2 print(3>2 or 3) #True
print(1 or 2)   --> 1
print(0 or 3)   --> 3
print(1 and 2)  --> 2  and与or正好相反
print(1 and 2>3) -->Flase
print(1>2 or 0 and 3<6 or 5) --> 5
0 or 5 < 4   -->False
8 or 3 and 4 or 2 and 0 or 9 and 7   -->True
0 or 2 and 3 and 4 or 6 and 0 or 3   -->False
3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2     -->2

and: 并且, 两端同时为真. 结果才能是真
or: 或者, 有一个是真. 结果就是真
not: 非真既假, 非假既真

顺序: () => not => and => or

x or y:
如果x是零, 输出y
如果x是非零, 输出x

True: 非零
False: 零

理解记忆  or 前面非零取前面 前面为零取后面;  and 与or 正好相反

特别注意:

0 or 5 < 4   -->False      print(-1 or 3)  -->  -1

编码部分:

1. ascii. 最早的编码. 至今还在使用. 8位一个字节(字符)
2. GBK. 国标码. 16位2个字节.
3. unicode. 万国码. 32位4个字节
4. UTF-8. 可变长度的unicode.
英文: 8位. 1个字节
欧洲文字:16位. 2个字节
汉字. 24位. 3个字节

8bit = 1byte
1024byte = 1KB
1024KB = 1MB
1024MB = 1GB
1024GB = 1TB

or and 运算符与 pyhton编码的更多相关文章

  1. day02 while循环 运算符 格式化输出 编码

     今日主要内容 while循环:判断条件是否成立. 如果成立执行循环体.然后再次判断条件,.....直到条件不成立的时候跳出循环 语法: while 条件: 循环体 else: 当条件不成立的时候执行 ...

  2. python:while循环、运算符、初始编码

    while循环 while -- 关键字 while 条件: 缩进代码块 以上循环是(死循环) 终止循环的方法 1.break 跳出循环,并且把循环给干掉了 2.continue 跳出本次循环,继续下 ...

  3. python -- while循环,格式化输出,运算符,初识编码

    一.while循环 1.语法 while   条件: 循环体(结果) 如果条件为真,则直接执行结果),然后再次判断条件,知道条件为假,停止循环. while True: print('你是谁呢') 退 ...

  4. Python学习笔记:第2天while循环 运算符 格式化输出 编码

    目录 1. while循环 continue.break和else语句 2. 格式化输出 3. 运算符 3.1 算数运算 3.2 比较运算符 3.3 赋值运算符 3.4 逻辑运算符 3.5 成员运算符 ...

  5. while循环语句、格式化输出、常用运算符、字符编码

    1.while循环 while 空格 条件 冒号 缩进 循环体 num=1 while num<11: print(num) num=num+1 变量都是先执行等号右边的,然后执行等号左边的. ...

  6. while 运算符 初始编码 python2和python3的区别

    1.while 循环 2.运算符 3.初始编码 4.python2 和python3的区别 1.while循环: 关键词:while[循环]         break[跳出循环]         c ...

  7. day02 循环、格式化输出、运算符、编码

    01 昨日内容回顾 python2x python3x区别: python2x:源码重复,不规范. python3x:源码规范,优美,清晰,简单. 编译型:将代码一次性全部转化成字节码. 代表语言:C ...

  8. python基础知识5---数据类型、字符编码、文件处理

    阅读目录 一 引子 二 数字 三 字符串 四 列表 五 元组 六 字典 七 集合 八 数据类型总结 九 运算符 十 字符编码 十一 文件处理 十二 作业   一 引子 1 什么是数据? x=10,10 ...

  9. sencha Touch 2.4 学习之 XTemplate模板

    XTemplate模板 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> & ...

随机推荐

  1. 从零开始学习SSH框架笔记之四 几个关键配置文件备忘(模板)

    不多说,直接上代码.关于注释我尽量写详细点. 1.web.xml <?xml version="1.0" encoding="UTF-8"?> &l ...

  2. LeetCode447. Number of Boomerangs

    Description Given n points in the plane that are all pairwise distinct, a "boomerang" is a ...

  3. hdu1018 Big Number 斯特林公式 求N!的位数。

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  4. Alluxio部署(local模式)

    下载(pre-build for Hadoop 2.7) http://www.alluxio.org/download` 解压 tar -xvf alluxio-1.3.0-hadoop2.7-bi ...

  5. Using Swift with Cocoa and Objective-C下载

    <Using Swift with Cocoa and Objective-C Building App > 下载地址 http://download.csdn.net/detail/sw ...

  6. openstack组件通讯端口定义

    openstack 组件通讯是通过ZeroMQ+ceilometer发送组件调用信息,具体是通过TCP通讯,发送数据和接收数据是用同一个端口(在配置文件指定),下面通过代码稍作解析: IceHouse ...

  7. 利用GetPrivateProfileString读取ini文件的字段

    //INIClass读取类 using System; using System.Collections.Generic; using System.Linq; using System.Text; ...

  8. 红外图像处理之直方图均衡的matlab源码与效果验证

    红外图像是热辐射成像,由于场景中的目标与背景的温差相对较小,红外图像的动态范围大.对比度 低, 信噪比也较可见光图像的低.为了能够从红外图像中正确地识别出目标,必须对红外图像进行增强处理.一般红外探测 ...

  9. day9笔记--文件操作

    文件操作  计算机系统分为:计算机硬件,操作系统,应用程序三部分. 我们用python或其他语言编写的应用程序若想要把数据永久保存下来,必须要保存于硬盘中,这就涉及到应用程序要操作硬件,众所周知,应用 ...

  10. PHP 微信错误状态返回码说明

    PHP 微信错误状态返回码说明 返回码说明 返回码    说明 -1   系统繁忙 0    请求成功 40001 验证失败 40002 不合法的凭证类型 40003 不合法的OpenID 40004 ...