当前位置: 首页 > news >正文

小企业网站模板脚本外链生成工具

小企业网站模板,脚本外链生成工具,wordpress媒体库上传,网站建设方面的书籍流程控制 顺序结构、条件结构、循环结构,顺序结构由自上而下的语句构成,条件结构由if、match-case构成,循环结构由for、while构成。 if语句 flag 1 if flag 1:print("A") elif flag 2:print("B") else:print("…

流程控制

顺序结构、条件结构、循环结构,顺序结构由自上而下的语句构成,条件结构由ifmatch-case构成,循环结构由forwhile构成。

if语句

flag = 1
if flag == 1:print("A")
elif flag == 2:print("B")
else:print("C")

match-case语句

结构模式匹配,Python3.10引入

PEP 634 – Structural Pattern Matching: Specification

PEP 635 – Structural Pattern Matching: Motivation and Rationale

PEP 636 – Structural Pattern Matching: Tutorial

# literal pattern
def structural_pattern_matching(value):match value:case 1:print("A")case "2":print("B")case True:print("C")case False:print("D")case None:print("E")structural_pattern_matching(1)
structural_pattern_matching("2")
structural_pattern_matching(None)
structural_pattern_matching("ABC")
# capture pattern
# guard是case的一部分,为if语句def structural_pattern_matching(value):match value:case {'sub': sub, **rest}:print(f'{sub=} {rest=}')case {'route': route}:print(f'ROUTE: {route}')structural_pattern_matching({'route': '/auth/login'})
structural_pattern_matching({'route': '/auth/login', 'sub': {'a': 1}})def go(obj):match obj:case 'go', [direction, num] if isinstance(num, int):print(f"go {direction} {num}")case 'stop', *other:print('stop', *other)go(['go', ['east', 3]])
go(['go', ['east', "3"]])
go(['stop', '3', '2', '1'])
# as pattern
def structural_pattern_matching(value):match value:case ["go", ("north" | "south" | "east" | "west") as direction]:print(f'go {direction}')case _:print("B")structural_pattern_matching(['go', 'west'])
# or pattern
def structural_pattern_matching(value):match value:case 0 | 1 | 2:print('A')case True | False:print('B')structural_pattern_matching(1)
# wildcard pattern
# 通配符,匹配任意值,通配符匹配必须要在最后
# SyntaxError: wildcard makes remaining patterns unreachable
def structural_pattern_matching(value):match value:case 1:print("A")case _:print("B")structural_pattern_matching(1)
structural_pattern_matching("2")
# Matching builtin classes
# 可以按类型匹配
def structural_pattern_matching(obj):match obj:case str() as s:print(s)case [0, tuple() as t]:print(f'{t}')case list() as l:print(l)structural_pattern_matching("ooo")  # ooo
structural_pattern_matching([0, (1,)])  # (1,)
structural_pattern_matching([(1,)])  # [(1,)]
structural_pattern_matching([1, 2, 3])  # [1, 2, 3]
# Matching positional attributes
from dataclasses import dataclassclass Point1:__match_args__ = ('x', 'y')def __init__(self, x, y):self.x = xself.y = y@dataclass
class Point2:x: inty: intdef structural_pattern_matching(value):match value:case Point1(x, y):print(f'{x=}, {y=}')case Point2(x, y):print(f'{x=}, {y=}')structural_pattern_matching(Point1(1, 2))
structural_pattern_matching(Point2(3, 4))

for语句

for i in range(10):print(i)
else:print("break跳出不执行else")

while语句

count = 10
while count:count -= 1print(count)# break# continue
else:print("循环正常执行完毕,没有被break打断")
http://www.hkea.cn/news/595999/

相关文章:

  • php网站开发 多少钱推广方案策划
  • 芜湖做网站公司广州seo好找工作吗
  • 做网站找客户百度竞价推广公司
  • 深圳网站建设怎么办互联网营销的优势
  • 课程网站开发背景网站推广的几种方法
  • 商城网站建设模板一份完整的营销策划方案
  • 推广网站建设网站权重查询工具
  • t型布局网站怎么做建设网官方网站
  • 哪个建设网站推广竞价托管公司
  • 网站建设傲seo网站是什么意思
  • 卢氏住房和城乡建设厅网站聚名网
  • 山东网站建设电话长沙靠谱的关键词优化
  • 山东营销型网站ip网站查询服务器
  • 什么网站上做奥数题企业培训课程清单
  • 龙岩优化seo是什么意思
  • 外贸网站建设源码软文怎么做
  • 文章列表页wordpress宁波seo资源
  • 获取网站访客qq 原理百度投诉中心人工电话
  • 企业网站制作查询百度电话怎么转人工
  • 杭州专业网站建设怎样创建网站
  • 网站建设报价表格式淘宝关键词优化技巧
  • 高端网站建设系统百度网盘登录入口官网
  • ps做网站顶部江苏网络推广公司
  • 源码做网站手机网站百度关键词排名
  • 网站关键词分隔网站链接提交
  • 福永营销型网站多少钱中国最新消息今天
  • 做网站4000-262-263网站排名优化软件有哪些
  • 网站双链接怎么做网络舆情监测平台
  • 企业网站建设制作百度网盘下载app
  • asp做一个简单网站网络营销就是seo正确吗