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来判断是否是浏览器

     

  • 相关阅读:
    MinIO:入门
    JS中面向对象的多种继承方式
    点击按钮实现图片下载
    给大家推荐一个免费的云平台-阿贝云
    REPLACE
    SUBSTRING_REGEXPR 截取字符串
    基本的git/linux/g++/ 等指令
    C++引用和指针&, *
    go语言异常处理 error panic recover defer
    django.db.utils.IntegrityError: (1048, "Column 'id' cannot be null")
  • 原文地址:https://www.cnblogs.com/luocongyu/p/11426958.html
Copyright © 2011-2022 走看看