首页 技术 正文
技术 2022年11月12日
0 收藏 792 点赞 4,097 浏览 2610 个字

今日内容1.while循环while Ture:            content = input (“请输入你要喷的内容”,输入Q退出)            if content == “”                continue(继续,如果是break就是直接退出循环)            if content == “Q”:                 break            print(“你对打野说”,content)最多说三次,通过count的大小来对册数进行限制count = 1while count <= 3:     # count = 1  # 次数, 死循环    content = input(“请输入你要喷的内容”)    print(“你要喷的内容:”, content)     # 改变count    count = count + 1打印出1到100的数count = 1while count <= 100:    print(count)    count = count + 1打印出1-100的和sum = 0count = 1while count <= 100:    sum = sum + count(sum += count)    count = count + 1print(sum)打出1-100的奇数count = 1while count <= 100:    print(count)    count = count + 2count = 1 while count <= 100:    print(count)    count = count + 2输入你知道的人名,如果输入人名是:xxx,输出的也是xxxwhile 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)  # Trueprint(3 > 4 or 4 < 3 and 1 == 1)  # Falseprint(1 < 2 and 3 < 4 or 1 > 2)  # Trueprint(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # Trueprint(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # Falseprint(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # Falseprint((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   否则返回xprint(1 or 2) # 1print(0 or 2) # 2print(3 or 0) # 3print(4 or 0) # 4当出现x and y的时候,和or相反的print(1 and 2) # 2print(0 and 3) # 0print(3 and 0) # 0print(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-81. 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 = 8bit1kb = 1024byte1mb = 1024kb1gb = 1024mb1tb = 1024gb1pb = 1024tb

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,087
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,562
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,821
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905