贺丹丹老公,师奶兵团粤语,太兴铁路
while也称为无限循环、死循环
while 条件:
缩进 循环体
while true:
print('-------------')
print('西北玄天一片云,')
print('乌鸦落入凤凰群,')
print('满桌都是英雄汉,')
print('谁是君来谁是臣。')
break -- 必须在while循环使用
braek -- 终止当前循环,且其下方的代码不会执行。
while true:
print('-------------')
print('西北玄天一片云,')
print('乌鸦落入凤凰群,')
print('满桌都是英雄汉,')
print('谁是君来谁是臣。')
break # 可放在循环体下面的任何条件后
改变循环体的条件也可以终止循环
f = true
while f:
print('-------------')
print('西北玄天一片云,')
print('乌鸦落入凤凰群,')
print('满桌都是英雄汉,')
print('谁是君来谁是臣。')
f = false # 可放在循环体下面的任何条件后
continue -- 跳出本次循环,继续下一次循环,其下方的代码不会执行。
(伪装成循环体的最后一行代码)
while true:
print('-------------')
print('西北玄天一片云,')
print('乌鸦落入凤凰群,')
print('满桌都是英雄汉,')
continue # 伪装成最后一行代码,不执行其下面的代码,继续无线循环
print('谁是君来谁是臣。')
占的位置填充时必须一一对应,填充的时候按照顺序填充,由左至右
%s —— 字符串类型
name = input("name:")
age = input("age:")
addr = input("addr:")
phone = input("phone:")
info = """
-----------info----------
姓名:%s
年龄:%s
公司:%s
电话:%s
------------end-----------
"""%(name,age,addr,phone)
print(info)
%d%i —— 数字类型
%% —— 转义
msg = "%s的学习进度是2%%"%(python)
print(msg)# %%转义是百分之二
f"{格式化}" —— 最好用的一种填充
%()
name = "qwert"
password = "1234"
num5 = 3
while num5 > 0:
names = input("请输入账号:")
psd = input("请输入密码:")
if name == names and password == psd:
print("登录成功")
break
print(f"输入错误,还有{num5-1}次机会。")
num5 -= 1
算数运算符
+
-
*
/
%取余
**次方
//整除(地板除) - 向下取整
比较运算符
< <= > >=
==等于
!=不等于
赋值运算符
= 赋值
+=加等于
-=减等于
*=乘等于
/=除等于
逻辑运算符
and 都为真,就是真:选择and后面的内容
有一个是假就是假:都为假的时候选择and前面的内容
or 只要有一个真就是真
两 的
两个都为假:选or后面的
not 不是,非
优先级别:() > not > and > 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
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
90
成员运算符
in 在
not in 不在
a = "alex"
if "b" not in a:
print("不在")
else:
print("在")
a = "alex"
if "b" in a:
print("在")
else:
print("不在")
ascii码 —— 美国自造,最早256位
英文一个字节
不支持中文
gbk —— 中国制造包含了ascii
中国标准语言——国标
英文1个字节,中文2个字节
万国码 unicode
utf-8 万国码的升级版本 最流行的密码本
英文1个字节
欧洲2个字节
亚洲3个字节
1bytes= 8bit 1个字节 == 8位
1kb = 1024b
1mb = 1024kb
1gb = 1024mb
1tb = 1024gb
1pb = 1024tb
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
python求numpy中array按列非零元素的平均值案例
网友评论