1,回顾昨天课程及作业

#1、使用while循环输入 1 2 3 4 5 6 8 9 10
'''
count = 0
while count < 10:
count += 1 # count = count + 1
if count == 7:
print(' ')
else:
print(count) count = 0
while count < 10:
count += 1 # count = count + 1
if count == 7:
continue
print(count)
'''
#3、输出 1-100 内的所有奇数
#方法一:
# count = 1
# while count < 101:
# print(count)
# count += 2
#方法二:
# count = 1
# while count < 101:
# if count % 2 == 1:
# print(count)
# count += 1 #5、求1-2+3-4+5 ... 99的所有数的和
# sum = 0
# count = 1
# while count < 100:
# if count % 2 == 0:
# sum = sum - count
# else:
# sum = sum + count
# count += 1
# print(sum) #6、用户登陆(三次机会重试)
#input 心中有账号,密码 while i = 0
while i < 3:
username = input('请输入账号:')
password = int(input('请输入密码:'))
if username == '咸鱼哥' and password == 123:
print('登录成功')
else:
print('登录失败请重新登录')
i += 1

2,格式化输出

#格式化输出
# % s d
# name = input('请输入姓名')
# age = input('请输入年龄')
# height = input('请输入身高')
# msg = "我叫%s,今年%s 身高 %s" %(name,age,height)
# print(msg)
"""
name = input('请输入姓名:')
age = input('请输入年龄:')
job = input('请输入工作:')
hobbie = input('你的爱好:') msg = '''------------ info of %s -----------
Name : %s
Age : %d
job : %s
Hobbie: %s
------------- end -----------------''' %(name,name,int(age),job,hobbie)
print(msg)
"""
name = input('请输入姓名')
age = input('请输入年龄')
height = input('请输入身高')
msg = "我叫%s,今年%s 身高 %s 学习进度为3%%s" %(name,age,height)
print(msg)

3,while else循环语句

count = 0
while count <= 5 :
count += 1
if count == 3:break
print("Loop",count) else:
print("循环正常执行完啦")
print("-----out of while loop ------")

4,初始编码

01010100        新
11010000 开
11010100 一
01100000 家
11000000 看
11000000 看 01010100011101110101011110110
A B C
01000001 01000010 01000011
电报,电脑的传输,存储都是01010101 最早的'密码本' ascii 涵盖了英文字母大小写,特殊字符,数字。
01010101
ascii 只能表示256种可能,太少,
创办了万国码 unicode
16表示一个字符不行,32位表示一个字符。
A 01000001010000010100000101000001
B 01000010010000100100001001000010
我 01000010010000100100001001000010
Unicode 升级 utf-8 utf-16 utf-32
8位 = 1字节bytes
utf-8 一个字符最少用8位去表示,英文用8位 一个字节
欧洲文字用16位去表示 两个字节
中文用24 位去表示 三个字节
utf-16 一个字符最少用16位去表示 gbk 中国人自己发明的,一个中文用两个字节 16位去表示。 11000000 1bit 8bit = 1bytes
1byte 1024byte = 1KB
1KB 1024kb = 1MB
1MB 1024MB = 1GB
1GB 1024GB = 1TB

5,逻辑运算

#and or not
#优先级,()> not > and > or
# print(2 > 1 and 1 < 4)
# print(2 > 1 and 1 < 4 or 2 < 3 and 9 > 6 or 2 < 4 and 3 < 2)
# T or T or F
#T or F
# print(3>4 or 4<3 and 1==1) # F
# print(1 < 2 and 3 < 4 or 1>2) # T
# print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T
# print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F
# print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F
# print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F #ps int ----> bool 非零转换成bool True 0 转换成bool 是False
# print(bool(2))
# print(bool(-2))
# print(bool(0))
# #bool --->int
# print(int(True)) # 1
# print(int(False)) # 0 '''x or y x True,则返回x'''
# print(1 or 2) # 1
# print(3 or 2) # 3
# print(0 or 2) # 2
# print(0 or 100) # 100 # print(2 or 100 or 3 or 4) # 2 # print(0 or 4 and 3 or 2)
'''x and y x True,则返回y'''
# print(1 and 2)
# print(0 and 2)
print(2 or 1 < 3)
print(3 > 1 or 2 and 2)

python编码问题和逻辑运算的更多相关文章

  1. (转载) 浅谈python编码处理

    最近业务中需要用 Python 写一些脚本.尽管脚本的交互只是命令行 + 日志输出,但是为了让界面友好些,我还是决定用中文输出日志信息. 很快,我就遇到了异常: UnicodeEncodeError: ...

  2. Python 编码简单说

    先说说什么是编码. 编码(encoding)就是把一个字符映射到计算机底层使用的二进制码.编码方案(encoding scheme)规定了字符串是如何编码的. python编码,其实就是对python ...

  3. Python之路3【知识点】白话Python编码和文件操作

    Python文件头部模板 先说个小知识点:如何在创建文件的时候自动添加文件的头部信息! 通过:file--settings 每次都通过file--setings打开设置页面太麻烦了!可以通过:View ...

  4. python编码规范

    python编码规范 文件及目录规范 文件保存为 utf-8 格式. 程序首行必须为编码声明:# -*- coding:utf-8 -*- 文件名全部小写. 代码风格 空格 设置用空格符替换TAB符. ...

  5. 【转】python编码的问题

    摘要: 为了在源代码中支持非ASCII字符,必须在源文件的第一行或者第二行显示地指定编码格式: # coding=utf-8 或者是: #!/usr/bin/python # -*- coding: ...

  6. 【转】python编码规范

    http://blog.csdn.net/willhuo/article/details/49300441 决定开始Python之路了,利用业余时间,争取更深入学习Python.编程语言不是艺术,而是 ...

  7. python 编码 UnicodeDecodeError

    将一个py脚本从Centos转到win运行,出错如下: UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: il ...

  8. Python编码/文件读取/多线程

    Python编码/文件读取/多线程 个人笔记~~记录才有成长   编码/文件读取/多线程 编码 常用的一般是gbk.utf-8,而在python中字符串一般是用Unicode来操作,这样才能按照单个字 ...

  9. 关于Python编码,超诡异的,我也是醉了

    Python的编码问题,真是让人醉了.最近碰到的问题还真不少.比如中文文件名.csv .python对外呈现不一致啊,感觉好不公平. 没图说个JB,下面立马上图.   我早些时候的其他脚本,csv都是 ...

随机推荐

  1. GIT如何从本地上传代码到github

    转载请标明出处: http://blog.csdn.net/hanhailong726188/article/details/46738929 本文出自:[海龙的博客] 开篇之前说下题外话,之前写过一 ...

  2. reference file contains errors

    一,问题分析 在学习 JavaWeb 的开发,很多时候我们会引用许多 JAR ,以为版本的问题,有时候就会出现这个问题:reference file contains errors (引用文件包含错误 ...

  3. DotNetCore跨平台~功能测试TestHost的使用

    回到目录 之前写了关于自动化测试的相关文章,包括gitlab,unittest,jenkins pipeline等,基于都是功能点的测试,当我们的框架或者业务修改之后,需要走一篇自动化测试,以此来保证 ...

  4. 变量声明declare,简单运算符运算,变量测试与内容替换

    declare -/+ 选项 变量名 - 设类型 + 取消类型 -i 设为整型 -x 设为环境变量 -p 显示类型属性(property) [root@localhost ~]# a= [root@l ...

  5. 【JMeter】选项-函数助手对话框应用举例

    String date="${__javaScript((new Date()).getFullYear()+'-'+((new Date()).getMonth()+1)+'-'+(new ...

  6. 浅谈Unix I/O模型

    关于I/O模型的文章比较多,参考多篇后理解上仍然不太满意,终需自己整理一次,也是编写高吞吐量高性能网络接口模块的基础.这里所说的主要针对网络I/O,近几年面对越来越大的用户请求量,如何优化这些步骤直接 ...

  7. 下篇: php 微商城 基于Thinkphp3.2框架开发

    (12)微信商城 ① 前台模板引入 a.引入微信商城模板的css+js+Images+img+bootstrap b.引入微商城的首页index.html及详情页detail.html页面模板 注意: ...

  8. Hosts文件实际应用 配置内部服务器提高访问效率和速度

    一 hosts文件的作用和介绍 https://jingyan.baidu.com/article/335530da45485e19cb41c3d6.html https://www.cnblogs. ...

  9. python+selenium自动化测试_1

    前言 回顾一下python+selenium基础,并整理相关知识点,分享给有需要,在前进道路上的朋友. print打印 #打印Hello World print("Hello World&q ...

  10. Android:Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

    今天开发Android项目时,导入了http有关架包后,程序编译报错如下: Error:Execution failed for task ':app:transformResourcesWithMe ...