zoukankan      html  css  js  c++  java
  • day 006

    day006

    0.1判断语法

    单分支结构

    if 条件成立输出

    双分支结构

    if 条件成立输出

    else 条件不成立输出

    多分支结构

    if

    elif(可无限写入)

    elif(无可限写入)条件成立输出

    elif(无可限写入)

    else

    score=(20)
    if score>=90:
      print('优秀')
    elif score>=80:
      print('良好')
    elif score>=70:
      print('普通')
    else:#or elif score<70:
      print('差')
    for i in range(1,13):
      for j in range(1,32):
          if i in[4,6,9,10,11] and j>30:
              continue
          '''if i<8and i % 2 == 0 and j>30:
              continue
          if i>7and i%2==1 and j>30:
              continue'''
          if i==2 and j>28:
              continue
          print(f'{i}月{j}日 运动')

    range(1,10) #依次输出数字1,2,3,……,8,9

    格式化输出

    字符串前面加上f,使{}内的字符定义为变量名

    for 循环嵌套;内层循环走完,才会走外层循环

    for + break;循环提前被结束,直接去往外层循环

    for + continue;跳过本次循环,直接进行下一次循环

    for i in range(1,13):
      for j in range(1,32):
          if i in[4,6,9,10,11] and j>30:
              continue
          '''if i<8and i % 2 == 0 and j>30:
              continue
          if i>7and i%2==1 and j>30:
              continue'''
          if i==2 and j>28:
              continue
          print(f'{i}月{j}日 运动')

    02爬虫

    爬虫三部曲:

    1.发送请求 2.解析数据 3.保存数据

    爬虫精髓

    1.分析网站的通信流程

    2.分析超找数据从何而来

    3.分析目标网站的反扒策略

    4.根据目标网站的反扒策略编写攻击手段,获取数据

    json

    是一种第三方的数据类型

    json.dumps() # 把python数据格式转换成 json 数据格式

    json.loads(). # 把 json 数据格式转换成python数据格式

    User-Agent

    一种反扒策略,通过User-Agent来判断是否是浏览器

     

  • 相关阅读:
    python 希尔排序
    python 选择排序
    python 插入排序
    怎么根据返回数量,来渲染点赞星星的个数变高量?
    avalon $computed不起作用?
    移动端点击事件兼容问题,在pc端可以点,在手机上不可以点
    移动端弹出遮罩层禁止页面滚动,遮罩里面的框允许滚动如何实现。
    移动端,如何禁止弹窗下面内容滚动/页面滚动
    avalon数据已更新,视图未更新的bug修复
    Python 导入分部分项前的 数据处理
  • 原文地址:https://www.cnblogs.com/luocongyu/p/11426958.html
Copyright © 2011-2022 走看看