1,使用while循环输出1,2,3,4,5,6,8,9

# 使用while循环输出1,2,3,4,5,6,8,9
num = 1
while num <= 10:
    if num != 7:
        print (num )
    num += 1

num = 1
while num < 10:
    num +=1
    if num ==7:
        continue
    print(num)

num = 1
while num < 10:
    num +=1
    if num ==7:
        pass
    else:
        print(num)

2,输出0-100内所有奇数的和

#输出0-100内所有奇数

num = 1
sum = 0
while num <=100:
    if num%2 !=0:
        sum +=num
    num +=1
print(sum)

num = 1
sum = 0
while num <=100:
    sum +=num
    num +=2
print(sum)

3,print long messge 注意变量类型,个数要对应的上,不然会报错

"""

Version     : 0.1
Author      : Lisa
Date        : 2018/11/25 8:02 AM
Description : 

"""

msg ='''--------------info of lisa------------

name:lisa
age:22
job:developer
Hobbies:piano,yoga

------------------end-----------------------'''
print(msg)

--------------info of lisa------------

name:lisa
age:22
job:developer
Hobbies:piano,yoga

------------------end-----------------------
"""

Version     : 0.1
Author      : Lisa
Date        : 2018/11/25 8:02 AM
Description : 

"""
age = int(input("please input your age:"))
name =input("please input your name:")
height=int(input("please input you height:"))
msg="my name is %s, i am %d, my height is %d" %(name,age,height)
print(msg)

please input your age:22
please input your name:lisa
please input you height:165
my name is lisa, i am 22, my height is 165

4,如果字符串里面已经有了单引号的三引号,那么外面要用栓双引号的三引号,不然会报错

5,字符串里面打印%

sg="my name is %s, i am %d, my height is %d,学习进度3%" %(name,age,height)
print(msg)
注意观察,这样写的话, pycharm字符串会标黄,提示语法有问题

运行结果
please input your age:22
please input your name:lisa
please input you height:165
Traceback (most recent call last):
  File "/Users/guolixiao/PycharmProjects/lisa's_practise/boys/2.1.py", line 12, in <module>
    msg="my name is %s, i am %d, my height is %d,学习进度3%" %(name,age,height)
ValueError: incomplete format

正确写法,应用%来转义
msg="my name is %s, i am %d, my height is %d,学习进度3%%" %(name,age,height)
print(msg)

运行结果:
please input your age:22
please input your name:lisa
please input you height:165
my name is lisa, i am 22, my height is 165,学习进度3%

输出%d
msg="my name is %s, i am %d, my height is %d,学习进度3%%d" %(name,age,height)
print(msg)

运行结果:
my name is lucy, i am 22, my height is 167,学习进度3%d

6,while else,只要while循环不被break跳出,else部分就会被执行

7,电脑的传输还有储存实际上都是0101010这种的,电脑的成千上万的二极管等设备可以实现高地电平

8,美国发明了ASCII码,由于英文字符加符号很少,所以一开始就设计了7位 可以储存128个字符,发明者还是有先见的,多用了一个第8位以防字符不够用,但是虽然这样,还是明显不够用,ASCII码最左边一位永远是0,中文汉字有9万多个,美国为了解决全球化的文字问题,发明了一个万国码也就是Unicode,一开始给了中文两个字节,但是只可以储存65535个字,明显不够用,后来给了四字节,但是又太多了,会造成很多浪费,中文3个字节足以,所以后来有了一个升级版本的万国码就是UTF-8,使用3个字节储存中文,一个字节表示英文,两个字节其他,GBK是中国人发明的,用两个字节表示一个汉字,只在国内用。

day2:day1作业 字符编码的更多相关文章

  1. Day1:字符编码

    一.ASCII码 ASCII(American Standard Code for Information Interchange,美国标准信息交换代码),8位,一个字节,最多只能表示255个符号. ...

  2. Python学习Day2笔记(字符编码和函数)

    1.字符编码 #ASCII码里只能存英文和特殊字符 不能存中文 存英文占1个字节 8位#中文编码为GBK 操作系统编码也为GBK#为了统一存储中文和英文和其他语言文字出现了万国码Unicode 所有一 ...

  3. 小白的Python之路 day2 字符编码和转码

    字符编码和转码 详细文章: http://www.cnblogs.com/yuanchenqi/articles/5956943.html http://www.diveintopython3.net ...

  4. 小白的Python之路 day1 字符编码

    字符编码 python解释器在加载 .py 文件中的代码时,会对内容进行编码(默认ascill) ASCII(American Standard Code for Information Interc ...

  5. Day2 - Python基础2 列表、字符串、字典、集合、文件、字符编码

    本节内容 列表.元组操作 数字操作 字符串操作 字典操作 集合操作 文件操作 字符编码与转码 1. 列表.元组操作 列表是我们最以后最常用的数据类型之一,通过列表可以对数据实现最方便的存储.修改等操作 ...

  6. Day1 字符编码及编码函数

    ord() 函数 获取字符的整数表示chr() 函数 把整数编码转换为对应字符'\十六进制编码\十六进制编码' 可以将字符的整数编码使用十六进制的方式这样写Python字符串类型为str,在内存中以u ...

  7. python学习笔记(基础一:'hello world'、变量、字符编码)

    第一个python程序: Hello World程序 windows命令行中输入:python,进入python交互器,也可以称为解释器. print("Hello World!" ...

  8. day07(数据类型的相互转换 ,字符编码)

    一,复习: ''' 1,深浅拷贝 ls = [1,'a',[10]] 值拷贝:直接赋值 ls1 = ls,ls中的任何值发生改变,ls1也随之发生改变 浅拷贝:通过copy()方法 ls2 = ls. ...

  9. python7 数据类型的相互转化 字符编码

    复习 1.深浅拷贝    ls = [1, 'a', [10]]    值拷贝:直接赋值 ls1 = ls, ls中的任何值发生改变,ls1中的值都会随之改变    浅拷贝:通过copy()方法 ls ...

随机推荐

  1. 一个vue请求接口渲染页面的例子

    new Vue({ el:'#bodylist', data: { list: [ { "type_id": "1", "type_name" ...

  2. Unity3d中的属性(Attributes)整理

    Attributes属性属于U3D的RunTimeClass,所以加上以下的命名空间是必须的了.其它倒没什么需要注意的.本文将所有运行属性过一遍罢了. using UnityEngine; using ...

  3. 使用tar解压文件提示gzip: stdin: not in gzip format错误

    使用tar解压文件提示gzip: stdin: not in gzip format错误 1. 问题描述 使用docker save xxxx > xxx.tar导出镜像,由于文件太大,需要sp ...

  4. SAP BW: Replacement Path Variables

    How to use Replacement Path Variables to perform Date Calculations A Step-by-Step guide Have you eve ...

  5. Linux 常用命令随笔(二)

    Linux 常用命令随笔(二) 1.RPM RPM是RedHat Package Manager(RedHat软件包管理工具) 1.1.安装软件包 rpm -ivh ***.rpm 其中i表示安装,v ...

  6. Android——Android和SVN::::SVN+delete项目

    SVN使用笔记(比较详细) http://www.cnblogs.com/merray/p/4182380.html 删除项目 http://jingyan.baidu.com/article/c74 ...

  7. Ubuntu 14.04 下搭建SVN服务器 (转载自 http://www.linuxidc.com/Linux/2015-01/111956.htm)-------------我所用到是红色字体

    http://www.linuxidc.com/Linux/2015-01/111956.htm Ubuntu 14.04 下搭建SVN服务器 svn:// 安装软件包: sudo apt-get i ...

  8. Ubuntu16.04搭建Postfix作为SMTP服务器

    一.DNS配置 类型 名称  值  TTL   A mail  128.199.254.32  1小时  MX  @ mail.example.com(优先:10) 1小时  TXT @  v=spf ...

  9. Maven 学习 -- 目录

    1. Maven 学习-入门 2. Maven学习-目录结构 3. Maven学习-处理资源文件 啦啦啦

  10. 技巧:Vim 的纵向编辑模式

    https://www.ibm.com/developerworks/cn/linux/l-cn-vimcolumn/ 开始之前 人类大脑对文字的处理是平面式的,所以我们浏览文章.查找资料或者重构代码 ...