Python从入门到网络爬虫、自动化

可以创建C++、C#、Python、Golang、Java、React、Node、Vue、PHP项目

创建Java项目

创建Python项目

简单if......else......语句

python 复制代码
# 简单的if......else......语句
state = True
if state:
    print("状态正常")
else:
    print("状态异常")

# 复杂的if......elif......语句
score = 88
def __getlevel__(score):
    level = ""
    if score >= 85 and score <=100:
        level = "A"
    elif score >=70 and score < 85:
        level = "B"
    elif score >=60 and score < 70:
        level = "C"
    elif score < 60:
        level = "D"
    return level
level = __getlevel__(score)
print("my level is :"+level)

# 嵌套if语句

Python从入门到精通

python 复制代码
'''
  条件语句
'''
# 普通if......else......语句
# 定义变量 存放状态
state = True


# 定义函数 计算状态
def getState(state):
  if state:
    print("状态启用")
  else:
    print("状态关闭")


# 调用函数 打印状态
getState(state)

# if......elif......语句
# 定义变量 存放得分
scored = 78


# 定义函数 计算等级
def getLevel(scored):
  # if else条件语句
  if scored >= 85 and scored <= 100:
    print("A")
  elif scored >= 70 and scored <= 84:
    print("B")
  elif scored >= 60 and scored <= 69:
    print("C")
  else:
    print("D")


# 调用函数 打印等级
getLevel(scored)

# if......else语句嵌套

# while循环语句
j = 1
# 简单while循环语句
while j < 10:
  print(j)
  j += 1

# while语句中使用 break、continue跳出循环
# while循环中使用break语句用于跳出整个循环
x = 0
while x < 10:
  x += 1
  if x % 2 == 0:
    break
  print("x:" + str(x))
# 输出 x:1

# while循环中continue语句用于跳出本次循环
while x < 10:
  x += 1
  if x % 2 == 0:
    continue
  print("x:" + str(x))
# 输出 x:1 x:3 x:5 x:7 x:9

# while......else......语句

# for循环语句
for i in range(1, 10):
  print("for:" + str(i))
# 循环字符串
for i in "python":
  print(i)
# 循环元组

# for......else......语句
for i in range(1,10):
  print(i)


# pass语句就是
if state:
  print("True")
else:
  pass
  print("False")
相关推荐
luyun0202026 分钟前
论坛里的小工具,吾爱出品
运维·服务器·windows
降临-max41 分钟前
Postman----接口自动化
软件测试·功能测试·自动化·postman
Miao121311 小时前
工程交付指标入门:如何重新掌控软件交付
大数据·运维·devops
涛声依旧393161 小时前
运维项目:InnoAI SQL 助手
运维·数据库·sql
养海绵宝宝的小蜗1 小时前
LVS(Linux Virtual Server)项目知识点总结
linux·运维·lvs
joopthd2 小时前
打破进口垄断:TDLAS/UV-DOAS/FTIR 全光谱检测国产器件全产业链布局(江苏旭海光电技术梳理)
运维·人工智能·uv·激光气体检测
云泽8082 小时前
Linux基础开发工具(三):Vim高级配置、Swap恢复机制与Sudo权限白名单详解
linux·运维·vim
Urbano3 小时前
服装厂入局自动化开袋设备:市场前景、机型选型与落地实效科普
运维·自动化
CodexDave3 小时前
Python 自动化接单实战(九):Windows 免环境交付如何打包与诊断
windows·python·自动化·python自动化·pyinstaller·软件交付·windows打包
tju23333 小时前
Gitee Test是什么:从测试资产管理到自动化执行的工程化实践
运维·gitee·自动化