今日内容
1.while循环
while Ture:
            content = input ("请输入你要喷的内容",输入Q退出)
            if content == ""
                continue(继续,如果是break就是直接退出循环)
            if content == "Q":
                 break
            print("你对打野说",content)
最多说三次,通过count的大小来对册数进行限制
count = 1
while count <= 3:
 
    # count = 1  # 次数, 死循环
    content = input("请输入你要喷的内容")
    print("你要喷的内容:", content)
 
    # 改变count
    count = count + 1
打印出1到100的数
count = 1
while count <= 100:
    print(count)
    count = count + 1
打印出1-100的和
sum = 0
count = 1
while count <= 100:
    sum = sum + count(sum += count)
    count = count + 1
print(sum)
打出1-100的奇数
count = 1
while count <= 100:
    print(count)
    count = count + 2
count = 1
 while count <= 100:
    print(count)
    count = count + 2
输入你知道的人名,如果输入人名是:xxx,输出的也是xxx
while True:
    name = input("你知道的人名,输入不知道直接退出:")
    if name == ("不知道"):
       continue
    print("你知道的名字:", name)
continue :  停止当前本次循环,继续执行写一次循环,不会彻底终端循环
break :  彻底干掉一个循环
能退出循环:    1.break        2.改变循环条件
2.格式化输出   %s  %d
%s  表示字符串的占位,全能的占位
坑:  如果这句话使用了格式化输出,%就是占位,如果想显示正常的%,输入%%转义
name = input("请输入你的名字:")    #input里面内容是字符串
address = input("请输入你来自哪里:")
wife = input("请输入你的老婆:")
notlike = input("请输入你不喜欢的明星:")
 
print("我叫"+name+", 我来自"+address+", 我老婆是"+wife+", 我不喜欢"+notlike)  
  #字符串的拼接
需要掌握的内容
#格式化输出
print("我叫%s, 我来自%s, 我老婆是%s, 我不喜欢%s" % (name, address, wife, notlike))
# 新版本的格式化输出
print(f"我叫{name}, 我来自{address}, 我老婆是{wife}, 我不喜欢{notlike}")
%d  占位数字,只能是数字
%s 表示字符串的占位 . 全能的占位.
print("周杰伦今年%s岁了" % 18)
# %d 占位数字. 只能放数字
print("周杰伦去年%d岁了" % 16)
print("周杰伦去年%d岁了" % "16") # 报错
3.运算符   
a.算是运算
+-*/ %**//
b.比较运算
print(3<>3)不等于
c.赋值运算
d.逻辑运算
and :并且.左右来两端同时为真,结果才能是真
or: 或者,左右两端有一个为真,结果就是真
not:  非,非真既假,非假既真     不真=假    不假=真
混合运算:运算顺序----()=>not=> and  =>or   当出现相同的运算的时候,从左往右算
print(3 > 2 or 5 < 7 and 6 > 8 or 7 < 5)  # True
print(3 > 4 or 4 < 3 and 1 == 1)  # False
print(1 < 2 and 3 < 4 or 1 > 2)  # True
print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # True
print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # False
print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # False
print((not 2 > 1 and 3 < 4) or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # False
当出现x or y的时候,判断x是否是0.如果x=0 then y   否则返回x
print(1 or 2) # 1
print(0 or 2) # 2
print(3 or 0) # 3
print(4 or 0) # 4
当出现x and y的时候,和or相反的
print(1 and 2) # 2
print(0 and 3) # 0
print(3 and 0) # 0
print(4 and 0) # 0
面试用的60%
False 当成0来看
print(False and 1)
print(3 > 5 or 5 < 6 and 7)
print(4 > 5 or 7 and 8 < 6 or 3 and 4)
e.成员运算:
content = input("请输入你的评论:")
if "马化腾" in content: # content中是否包含了xxx
    print("你的评论不合法")
else:
    print("你的评论是合法的")
 
ad = input("请输入你的广告:")
if "最" in ad or "第一" in ad or "全球" in ad:
    print("不合法的")
 
else:
    print("合法的")
4.初识编码      gbk  unicode  utf-8
1. ascii   8bit  1byte(字节)  256个码位 只用到了7bit, 用到了前128个 最前面的一位是0
    2. 中国人自己对计算机编码进行统计. 自己设计. 对ascii进行扩展 ANSI 16bit -> 清华同方 -> gbk
        GBK 放的是中文编码. 16bit  2byte 兼容ascii
    3. 对所有编码进行统一. unicode. 万国码.  32bit. 4byte. 够用了但是很浪费
 
    4. utf-8 可变长度的unicode
        英文: 1byte
        欧洲文字: 2byte
        中文: 3byte
字节(byte)
1byte = 8bit
1kb = 1024byte
1mb = 1024kb
1gb = 1024mb
1tb = 1024gb
1pb = 1024tb

while 循环,格式化输出和运算编码的更多相关文章

  1. while循环 格式化输出 密码本 编码的初识

    第二天课程整理 while 循环 why : while ' 循环' 的意思 what : while 无限循环 how : 1.基本结构 while + 条件 循环的代码 初识循环 while tr ...

  2. python之while循环/格式化输出/运算符/初始编码/成员变量

    一.主要内容:1.while 循环 (难点)while 条件: 循环体 break: 直接跳出循环continue:停止当前本次循环,继续执行下一次循环.不会中断循环能让循环退出:(1)break ( ...

  3. python全栈 流程控制;while 循环 格式化输出 运算符 及编码

    python全栈开发 1循环 2break和continue的区别 3格式化输出 4运算符 5编码 一.流程控制while循环 while条件: 代码块(循环体) 1.死循环; while True; ...

  4. while循环,格式化输出,运算符及编码初识

    一.while循环 1.基本循环(死循环) while 条件: 循环体 2.使用while计数 count = 0 # 数字里面非零的都为True while True: count = count ...

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

    一.while循环 1.基本结构 while 条件:            循环体   流程: 判断条件是否为真. 如果真, 执行代码块. 然后再次判断条件是否为真 .如果真继续执行代码块....  ...

  6. DAY2---Python---While循环,格式化输出,运算符,编码

    一.while循环 while 条件: 代码块(循环体) 流程:判断条件是否为真,如果是真,执行代码块.然后再次判断条件是否为真,如果为真继续执行代码块... 直到条件变成了假,退出循环 #死循环:永 ...

  7. 总结day2 ---- while循环的简单使用, 格式化输出.运算符.以及编码的应用

    内容提要 一 : while 循环 while 的基本语句操作 如何终止循环 二 :格式化输出 三 :运算符号 四 :编码初识别 一 : while 循环 1  >>>>whi ...

  8. 第二天-while循环 格式化输出 运算符 编码

    一.while循环 while 条件: 语句块(循环体)     #判断条件是否成立,若成立执行循环体,然后再次判断条件...直到不满足跳出循环 else: 当条件不成立的时候执行这里,和break没 ...

  9. day_02 循环格式化输出编码运算符

    1.while循环 语法 while 条件: 循环体 else: 当条件不成立的时候执行这里,和break没关系 如果循环是通过break退出的. 那么while后面的else将不会被执行, 只有在w ...

随机推荐

  1. LeetCode-Subsets ZZ

    LeetCode:Subsets Given a set of distinct integers, S, return all possible subsets. Note: Elements in ...

  2. xtrabackup在线迁移mysql并搭建为主主同步

    一.背景 工作中有需求数据库需要迁移,但是不能停服,不能锁库锁表影响业务的正常运行,所以使用XtraBackup 二.环境: 操作系统:CentOS Linux release 7.4.1708 (C ...

  3. July 23rd 2017 Week 30th Sunday

    Setting goals is the first step in turning the invisible into the visible. 设定目标是将实现梦想的第一步. If you wa ...

  4. C#检验IIS版本、SQL Server版本、SilverLight版本

    之前做一个小项目,使用C#检验这些软件的版本,到处找了一些代码,也能作用,记录一下,以防以后用到. 一.检验IIS版本 public static bool checkIIS(string destV ...

  5. 有趣的IntegerCache

    一个很有趣的现象,下面这两个结果输出的结果是false true,这是为什么?   翻看Integer的源码可以看到,当new Integer(12);时,没有什么特别的,就是通过构造方法创建了一个I ...

  6. ListView实现下拉刷新(二)隐藏头布局

    一.问题分析 在上一篇中,我们将头布局加到了ListView上.但是没有隐藏他.你可能会想,隐藏还不简单,直接给它设置为GONE属性不就可以了吗,在需要的时候再设定为可见.没错,这正是ListView ...

  7. log4j框架logger的继承关系以及使用场景

    log4j框架logger的继承关系以及使用场景 log4j日志框架logger是存在继承关系的,我们一般都会在log4j.properties文件中定义log4j.rootLogger.其他所有lo ...

  8. UVa 1442 - Cave

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. jquery ajax 标准写法

    $.ajax({ url:"http://www.microsoft.com", //请求的url地址 dataType:"json", //返回格式为json ...

  10. Python re模块正则表达式