while
While 条件 :
循环体
while ture : (死循环)
Print ("我爱你")
Print ("我爱你")
Print ("我爱你")
num = 2
While num > 2 :
Print ("我爱你")
num = num - 1
while True :
Print ("我爱你")
break-------------------结束当前本层循环
while Ture :
print("我爱你")
print("我很爱你")
continue---------------结束当前本次循环----------continue后的就不在循环
print("我恨你")
使用while 输出10 - 57的数
num = 10
While num <= 57:
print(num)
Num =num + 1
While else
While Ture :
Print (123)
break
Print (234) 只打印一次 123 不再打印234
flag = True
While flage :
Print (123)
flag = False
Print (234) 打印出来的是 123 234
flag = Ture
While flag :
Print (123)
flag = False
else :
print(234) 打印出来的是 123 234
While Ture :
Print (123)
break
else :
print(234) 不再执行else 彻底结束本层循环 结果是只打印123
Flag = True
while flag :
Print (123)
Flag = False
else:
print(input(">>>")) 打印的结果是123 ">>>"
while循环 -- 死循环
代码块
原始的办法
-----------info----------
姓名:
年龄:
公司:
电话:
------------end-----------
"""
name = input ("name:")
age = input("age")
add = input("addr")
Phone = input("phone")
a = "-----------info—————"
b = "姓名" +name
c = "年龄" + age
d = "地址"+addr
e = "电话" +phone
f = "------------end—————"
Print (a)
print(b)
print(c)
print(d)
print(e)
print(f)
使用字符串
-----------info----------
姓名:
年龄:
公司:
电话:
------------end-----------
name = input ("name:")
age = input("age")
add = input("addr")
Phone = input("phone")
info = """
-----------info----------
姓名 : %s
年龄: %s
公司:%s
电话:%s
------------end-----------
"""%(name , age , addr , phone)
print( info )
f 语句
mag = f """-----------info----------
姓名:{input('name')}
年龄:{input('age')}
公司:{input('addr')}
电话:{input('phone')}
------------end-----------"""
print(msg)
msg = "%s的学习进度是2%%"%(1.5)
print(msg)
python3.6版本及以上才能使用
name = "日魔"
print(f"{name}的学习进度2%")
print(f"{input('>>>')},{23},{34},{45}")
print(f"{'meet'},{15},{'女'}")
msg = f"""-----------info----------
姓名:{input('name')}
年龄:{input('age')}
公司:{input('addr')}
电话:{input('phone')}
------------end-----------"""
print(msg)
%s -- 占字符串的位置(%s数字,字符串都能够进行填充)
%d|%i -- 占数字的位置
%% 转义 -- 转换成普通的百分号
占的位置和填充时必须要一一对应
填充的时候按照顺序填充
f"" python3.6版本及以上才能使用
运算符
算术运算: + - * / ** // %(取余)
比较运算:< > <= >= ==(等于) !=(不等于)
赋值运算符: = += -= /= *= **= %= //=
逻辑运算符 () and or not
优先级 : 先算 not 再算and 再算 or
Ture and False
and 的运算,都为真才是真,有一个是假就是假
and 的运算,都为真的的时候选择and后边的内容
*and 的运算,都为假的的时候选择and前边的内容
or 的运算,只要有一个真就是真
or 的运算,都为真的的时候选择or前边的内容
or 的运算,都为假的的时候选择or后边的内容
非 -- 不是
9 or 8 and 4 and not 4 < 5 or 8
9 or 8 and 4 and False or 8
9 or 4 and False or 8
9 or False or 8
9 or 8
9
8 and 9 or not False and 15
8 and 9 or True and 15
8 and 9 or 15
9 or 15
not 3<5 and 6>3 or 6 and not True or False and 8 or 90
False and 6>3 or 6 and not True or False and 8 or 90
False and 6>3 or 6 and False or False and 8 or 90
False or 6 and False or False and 8 or 90
False or False or False and 8 or 90
False or False or False or 90
And 和 or 相反
当一个运算式子中有or 并且前是真 输出答案一定为真
成员运算符
in
not in
a = "alex"
if "b" not in a:
print("不在")
else:
print("在")
a = "alex"
if "b" in a:
print("在")
else:
print("不在")
编码初识
ascii 256
1字节
不支持中文
gbk(国标)
0101 你
0111 好
英文 1字节
中文 2字节
今 0101
晚 0110
咱 1001
们 1111
去 1010
洗 1100
澡 1011
000001010000011000001001000011110000101011001011
万国码 unicode
中文和英文4个字节
1字节 == 8位
utf-8 最流行的编码集(密码本)
英文 1
欧洲 2
亚洲 3
win - 编码gbk
linux - 编码utf-8
mac - 编码utf-8
ascii码:
不支持中文
1个字节
gbk(国标):
英文 1个字节
中文 2个字节
unicode(万国码)
英文 4个字节
中文 4个字节
utf-8
英文1个字节
欧洲2个字节
亚洲3个字节
单位转换:
1字节 == 8位 <==> 1B == 8b *****
1B = 8b
1KB = 1024B
1MB = 1024KB
1GB = 1023MB
1TB = 1024GB # 最常用的就是TB
1PB = 1024TB
1EB = 1024PB## while
While 条件 :
循环体
while ture : (死循环)
Print ("我爱你")
Print ("我爱你")
Print ("我爱你")
num = 2
While num > 2 :
Print ("我爱你")
num = num - 1
while True :
Print ("我爱你")
break-------------------结束当前本层循环
while Ture :
print("我爱你")
print("我很爱你")
continue---------------结束当前本次循环----------continue后的就不在循环
print("我恨你")
使用while 输出10 - 57的数
num = 10
While num <= 57:
print(num)
Num =num + 1
While else
While Ture :
Print (123)
break
Print (234) 只打印一次 123 不再打印234
flag = True
While flage :
Print (123)
flag = False
Print (234) 打印出来的是 123 234
flag = Ture
While flag :
Print (123)
flag = False
else :
print(234) 打印出来的是 123 234
While Ture :
Print (123)
break
else :
print(234) 不再执行else 彻底结束本层循环 结果是只打印123
Flag = True
while flag :
Print (123)
Flag = False
else:
print(input(">>>")) 打印的结果是123 ">>>"
while循环 -- 死循环
代码块
原始的办法
-----------info----------
姓名:
年龄:
公司:
电话:
------------end-----------
"""
name = input ("name:")
age = input("age")
add = input("addr")
Phone = input("phone")
a = "-----------info—————"
b = "姓名" +name
c = "年龄" + age
d = "地址"+addr
e = "电话" +phone
f = "------------end—————"
Print (a)
print(b)
print(c)
print(d)
print(e)
print(f)
使用字符串
-----------info----------
姓名:
年龄:
公司:
电话:
------------end-----------
name = input ("name:")
age = input("age")
add = input("addr")
Phone = input("phone")
info = """
-----------info----------
姓名 : %s
年龄: %s
公司:%s
电话:%s
------------end-----------
"""%(name , age , addr , phone)
print( info )
f 语句
mag = f """-----------info----------
姓名:{input('name')}
年龄:{input('age')}
公司:{input('addr')}
电话:{input('phone')}
------------end-----------"""
print(msg)
msg = "%s的学习进度是2%%"%(1.5)
print(msg)
python3.6版本及以上才能使用
name = "日魔"
print(f"{name}的学习进度2%")
print(f"{input('>>>')},{23},{34},{45}")
print(f"{'meet'},{15},{'女'}")
msg = f"""-----------info----------
姓名:{input('name')}
年龄:{input('age')}
公司:{input('addr')}
电话:{input('phone')}
------------end-----------"""
print(msg)
%s -- 占字符串的位置(%s数字,字符串都能够进行填充)
%d|%i -- 占数字的位置
%% 转义 -- 转换成普通的百分号
占的位置和填充时必须要一一对应
填充的时候按照顺序填充
f"" python3.6版本及以上才能使用
运算符
算术运算: + - * / ** // %(取余)
比较运算:< > <= >= ==(等于) !=(不等于)
赋值运算符: = += -= /= *= **= %= //=
逻辑运算符 () and or not
优先级 : 先算 not 再算and 再算 or
Ture and False
and 的运算,都为真才是真,有一个是假就是假
and 的运算,都为真的的时候选择and后边的内容
*and 的运算,都为假的的时候选择and前边的内容
or 的运算,只要有一个真就是真
or 的运算,都为真的的时候选择or前边的内容
or 的运算,都为假的的时候选择or后边的内容
非 -- 不是
9 or 8 and 4 and not 4 < 5 or 8
9 or 8 and 4 and False or 8
9 or 4 and False or 8
9 or False or 8
9 or 8
9
8 and 9 or not False and 15
8 and 9 or True and 15
8 and 9 or 15
9 or 15
not 3<5 and 6>3 or 6 and not True or False and 8 or 90
False and 6>3 or 6 and not True or False and 8 or 90
False and 6>3 or 6 and False or False and 8 or 90
False or 6 and False or False and 8 or 90
False or False or False and 8 or 90
False or False or False or 90
And 和 or 相反
当一个运算式子中有or 并且前是真 输出答案一定为真
成员运算符
in
not in
a = "alex"
if "b" not in a:
print("不在")
else:
print("在")
a = "alex"
if "b" in a:
print("在")
else:
print("不在")
编码初识
ascii 256
1字节
不支持中文
gbk(国标)
0101 你
0111 好
英文 1字节
中文 2字节
今 0101
晚 0110
咱 1001
们 1111
去 1010
洗 1100
澡 1011
000001010000011000001001000011110000101011001011
万国码 unicode
中文和英文4个字节
1字节 == 8位
utf-8 最流行的编码集(密码本)
英文 1
欧洲 2
亚洲 3
win - 编码gbk
linux - 编码utf-8
mac - 编码utf-8
ascii码:
不支持中文
1个字节
gbk(国标):
英文 1个字节
中文 2个字节
unicode(万国码)
英文 4个字节
中文 4个字节
utf-8
英文1个字节
欧洲2个字节
亚洲3个字节
单位转换:
1字节 == 8位 <==> 1B == 8b *****
1B = 8b
1KB = 1024B
1MB = 1024KB
1GB = 1023MB
1TB = 1024GB # 最常用的就是TB
1PB = 1024TB
1EB = 1024PB