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

日撸 Java 三百行day1-10

文章目录

    • 说明
    • day1 环境搭建
      • 1.1 开发环境
      • 1.2 package import 和 println
      • 1.3 编写HelloWorld.java
    • day2 基本算术操作
      • 2.1 加、减、乘、除、整除、取余.
    • day3 基本if 语句
      • 3.1 if条件分支语句
      • 3.2 代码
    • day4 闰年的计算
      • 4.1 思路整理:何为闰年?
      • 4.2 核心代码
    • day5 基本switch 语句
      • 5.1 switch也属于条件分支语句
      • 5.2 思考
    • day6 基本for 语句
      • 6.1 for语句中表达式的执行顺序
      • 6.2 代码
    • day7 矩阵元素相加
      • 7.1 题目解读
      • 7.2 二维数组中
    • day8 矩阵相乘
      • 8.1 题目解读
      • 8.2代码
    • day9 while 语句
      • 代码
    • day10 综合任务 1
      • 10.1 题目解读
      • 10.2 代码
    • 自我小结
      • 三大结构

说明

闵老师的文章链接: 日撸 Java 三百行(总述)_minfanphd的博客-CSDN博客

自己也把手敲的代码放在了github上维护:https://github.com/fulisha-ok/sampledata

day1 环境搭建

1.1 开发环境

在搭建java环境时,从官网下载了java安装包安装成功后,一定要正确配置环境变量

1.2 package import 和 println

(1)package包:就好似我们日常生活中的”收纳盒“,不同的”收纳盒“装不同的”物品“,方便我们查找和定位。在大”收纳盒“中有包含各种小”收纳盒“,这也体现了包是以树形结构存储的。

package com //一个主包
package com.project //主包下建一个项目工程包
package com.project.util //一个工具包,util工具包在com目录下的project目录中

(2)import:导入包成员,在写一个java类时,我们需用到其他包中的成员,此时就需要通过import导入相应的包,则就好似c语言需要导入头文件,才能用一些库里的函数

import java.util.ArrayList;; //导入Java util包下的ArrayList 那则可以用这个类中一些方法,变量
import java.util.*; //导入util包下所有的东西,那我们使用的范围就比上面这个更多

(3)println:打印输出语句,且在输出后会自动换行,若不换行则是print

1.3 编写HelloWorld.java

main函数是程序入口

package basic;
public class HellowWorld {public static void main(String[] args) {System.out.println("Hello, World");}
}

day2 基本算术操作

2.1 加、减、乘、除、整除、取余.

package basic;public class BasicOperations {public static void main(String args[]) {int tempFirstInt, tempSecondInt, tempResultInt;double tempFirstDouble, tempSecondDouble, tempResultDouble;tempFirstInt = 15;tempSecondInt = 4;tempFirstDouble = 1.2;tempSecondDouble = 3.5;//AdditiontempResultInt = tempFirstInt + tempSecondInt;tempResultDouble = tempFirstDouble + tempSecondDouble;System.out.println("" + tempFirstInt + " + " + tempSecondInt + " = " + tempResultInt);System.out.println("" + tempFirstDouble + " + " + tempSecondDouble + " = " + tempResultDouble);//SubtractiontempResultInt = tempFirstInt - tempSecondInt;tempResultDouble = tempFirstDouble - tempSecondDouble;System.out.println("" + tempFirstInt + " - " + tempSecondInt + " = " + tempResultInt);System.out.println("" + tempFirstDouble + " - " + tempSecondDouble + " = " + tempResultDouble);//MultiplicationtempResultInt = tempFirstInt * tempSecondInt;tempResultDouble = tempFirstDouble * tempSecondDouble;System.out.println("" + tempFirstInt + " * " + tempSecondInt + " = " + tempResultInt);System.out.println("" + tempFirstDouble + " * " + tempSecondDouble + " = " + tempResultDouble);//DivisiontempResultInt = tempFirstInt / tempSecondInt;tempResultDouble = tempFirstDouble / tempSecondDouble;System.out.println("" + tempFirstInt + " / " + tempSecondInt + " = " + tempResultInt);System.out.println("" + tempFirstDouble + " / " + tempSecondDouble + " = " + tempResultDouble);//ModulustempResultInt = tempFirstInt % tempSecondInt;System.out.println("" + tempFirstInt + " % " + tempSecondInt + " = " + tempResultInt);}
}

在这里插入图片描述

day3 基本if 语句

3.1 if条件分支语句

其中,if中的表达式应该为布尔表达式。这里会存在三种不同选择。(假设在if中会有数据的处理)

第一,只使用if语句,这相当于我只过滤我想要的数据;

第二:if…else 语句,(不入if就进else, 非真即假)

第三:if…else if…else 语句,这就是多条件分支判断。对不同条件进行判断

3.2 代码

package basic;public class IfStatement {/*** The entrance of the program* @param args*/public static void main(String args[]) {int tempNumber1, tempNumber2;// Try a positive valuetempNumber1 = 5;if (tempNumber1 >= 0) {tempNumber2 = tempNumber1;} else {tempNumber2 = -tempNumber1;} // Of ifSystem.out.println("The absolute value of " + tempNumber1 + " is " + tempNumber2);// Try a negative value// Lines 27 through 33 are the same as Lines 15 through 19tempNumber1 = -3;if (tempNumber1 >= 0) {tempNumber2 = tempNumber1;} else {tempNumber2 = -tempNumber1;} // Of ifSystem.out.println("The absolute value of " + tempNumber1 + " is " + tempNumber2);// Now we use a method/function for this purpose.tempNumber1 = 6;System.out.println("The absolute value of " + tempNumber1 + " is " + abs(tempNumber1));tempNumber1 = -8;System.out.println("The absolute value of " + tempNumber1 + " is " + abs(tempNumber1));}/*** @param paraValue The given value.* @return  The absolute value of the given parameter.*/public static int abs(int paraValue) {if (paraValue >= 0) {return paraValue;} else {return -paraValue;}}
}

在这里插入图片描述

day4 闰年的计算

4.1 思路整理:何为闰年?

(1)非世纪年(不能被100整除的年份)能被4整除且不能被100整除的年份为闰年
(2)世纪年 能被400整除的才是闰年
文中给出两种计算闰年的方法,结合day3的if语句,第一种把所有逻辑判断放在一个if中完成,会使用一些与或非逻辑运算,如果逻辑判断条件过多,如果放在一个if判断中则会增加代码的可维护性,但第二种方法是一个条件一个条件判断,如果其中有一个不满足就退出,这样是根据if-else if顺序执行,来判断只有有不符合条件就退出、

4.2 核心代码

 /*** @param paraYear* @return Is the given year leap? true or false;*/public static boolean isLeapYear(int paraYear) {if ((paraYear % 4 == 0) && (paraYear % 100 != 0) || (paraYear % 400 == 0)) {return true;} else {return false;}}/*** @param paraYear* @return Is the given year leap? Replace the complex condition with a number of if. return true or false*/public static boolean isLeapYearV2(int paraYear) {if (paraYear % 4 != 0) {return false;} else if (paraYear % 400 == 0) {return true;} else if (paraYear % 100 == 0) {return false;} else {return true;}}

day5 基本switch 语句

5.1 switch也属于条件分支语句

switch中表达式的值去和case后的值做匹配,若匹配正确则执行其后需要执行代码,遇到break结束执行。若没有case匹配,则最后就会执行default,default 分支不需要 break 语句

5.2 思考

(1)每一个case后都要跟break吗?
答案是否定的。不加break的话将会跳转到相应的case去执行且其以下的所有语句。
(2)switch和if条件语句有什么区别呢?
最明显差异是表示执行的结构,if中的表达式结果只能是boolean类型,而switch恰恰相反,他表示式结果可以是int,char等。我在实际使用过程中if语句用的比较多,但涉及到判断的if分支较多时,我会考率使用switch,这样效率会高一点

day6 基本for 语句

6.1 for语句中表达式的执行顺序

for(a;b;c)其中a,b,c为表达式,执行顺序:先执行a表达式,一般为初始化语句,再执行b表达式,一般式判断表达式,若为ture去执行循环体,执行完再执行c表达式,若不满足b表达式,则跳出循环。

6.2 代码

package basic;
public class ForStatement {/*** The entrance of the program.* @param args*/public static void main(String[] args) {forStatementTest();}/*** Method unit test.*/public static void forStatementTest(){int tempN = 0;System.out.println("1 add to " + tempN + " is: " + addToN(tempN));tempN = 0;System.out.println("1 add to " + tempN + " is: " + addToN(tempN));int tempStepLength = 1;tempN = 10;System.out.println("1 add to " + tempN + " with step length " + tempStepLength + " is: "+ addToNWithStepLength(tempN, tempStepLength));tempStepLength = 2;System.out.println("1 add to " + tempN + " with step length " + tempStepLength + " is: "+ addToNWithStepLength(tempN, tempStepLength));}/*** Add from 1 to N.* @param paraN The given upper bound.* @return The sum.*/public static int addToN(int paraN) {int resultSum = 0;for (int i = 1; i <= paraN; i++) {resultSum += i;}return resultSum;}/*** Add from 1 to N with a step length.* @param paraN The given upper bound.* @param paraStepLength paraStepLength The given step length.* @return The sum.*/public static int addToNWithStepLength(int paraN, int paraStepLength) {int resultSum = 0;for (int i = 1; i <= paraN; i += paraStepLength) {resultSum += i;}return resultSum;}
}

day7 矩阵元素相加

7.1 题目解读

矩阵用二维数组存储,计算二维数组的和,计算两个二维数组对应行列相加组成一个新的二维数组,都需要用到for循环遍历(行优先);对矩阵的赋值也需要循环遍历赋初值,在有循环时要避免死循环,确保循环是有限性的。

7.2 二维数组中

int[][] tempMatrix = new int[3][4];
tempMatrix.length; //代表行的长度
tempMatrix[0].length; //代表列的长度

代码:

package basic;import java.util.Arrays;
public class MatrixAddition {public static void main(String[] args) {matrixElementSumTest();matrixAdditionTest();}/*** Sum the elements of a matrix.* @param paraMatrix* @return  The sum of all its elements.*/public static int matrixElementSum(int[][] paraMatrix) {int resultSum = 0;for (int i = 0; i < paraMatrix.length; i++) {for (int j = 0; j < paraMatrix[0].length; j++) {resultSum += paraMatrix[i][j];}}return resultSum;}/*** Unit test for respective method*/public static void matrixElementSumTest() {int[][] tempMatrix = new int[3][4];for (int i = 0; i < tempMatrix.length; i++) {for (int j = 0; j < tempMatrix[0].length; j++) {tempMatrix[i][j] = i * 10 + j;}}System.out.println("The matrix is: \r\n" + Arrays.deepToString(tempMatrix));System.out.println("The matrix element sum is: " + matrixElementSum(tempMatrix) + "\r\n");}/*** Add two matrices. Attention: NO error check is provided at this moment.* @param paraMatrix1 The first matrix.* @param paraMatrix2 The second matrix. It should have the same size as the first one's* @return The addition of these matrices.*/public static int[][] matrixAddition(int[][] paraMatrix1, int[][] paraMatrix2) {int[][] resultMatrix = new int[paraMatrix1.length][paraMatrix1[0].length];for (int i = 0; i < paraMatrix1.length; i++) {for (int j = 0; j < paraMatrix1[0].length; j++) {resultMatrix[i][j] = paraMatrix1[i][j] + paraMatrix2[i][j];}}return resultMatrix;}/*** Unit test for respective method.*/public static void matrixAdditionTest() {int[][] tempMatrix = new int[3][4];for (int i = 0; i < tempMatrix.length; i++) {for (int j = 0; j < tempMatrix[0].length; j++) {tempMatrix[i][j] = i * 10 + j;}}System.out.println("The matrix is: \r\n" + Arrays.deepToString(tempMatrix));int[][] tempNewMatrix = matrixAddition(tempMatrix, tempMatrix);System.out.println("The new matrix is: \r\n" + Arrays.deepToString(tempNewMatrix));}
}

day8 矩阵相乘

8.1 题目解读

矩阵相乘(只有第一个矩阵的列和第二个矩阵的行相等): a矩阵(mn),b矩阵(np)则能相乘,且相乘后的矩阵为m*p。故在矩阵相乘是在一定条件下才能进行,需要用到if判断。
在这里插入图片描述

8.2代码

package basic;import java.util.Arrays;public class MatrixMultiplication {public static void main(String[] args) {matrixMultiplicationTest();}/*** Matrix multiplication. The columns of the first matrix should be equal to the rows of the second one.* @param paraFirstMatrix The first matrix.* @param paraSecondMatrix The second matrix* @return The result matrix.*/public static int[][] multiplication(int[][] paraFirstMatrix, int[][] paraSecondMatrix){//m*n n*p == m*pint m = paraFirstMatrix.length;int n = paraFirstMatrix[0].length;int p = paraSecondMatrix[0].length;// Step 1. Dimension check.if (paraSecondMatrix.length != n) {System.out.println("The two matrices cannot be multiplied.");return null;}// Step 2. The loop. m*n n*p == m*pint[][] resultMatrix = new int[m][p];for (int i = 0; i < m; i++) {for (int j = 0; j < p; j++) {for (int k = 0; k < n; k++) {resultMatrix[i][j] += paraFirstMatrix[i][k] * paraSecondMatrix[k][j];}}}return resultMatrix;}public static void  matrixMultiplicationTest(){int[][] tempFirstMatrix = new int[2][3];for (int i = 0; i < tempFirstMatrix.length; i++) {for (int j = 0; j < tempFirstMatrix[0].length; j++) {tempFirstMatrix[i][j] = i + j;}}System.out.println("The first matrix is: \r\n" + Arrays.deepToString(tempFirstMatrix));int[][] tempSecondMatrix = new int[3][2];for (int i = 0; i < tempSecondMatrix.length; i++) {for (int j = 0; j < tempSecondMatrix[0].length; j++) {tempSecondMatrix[i][j] = i * 10 + j;}}System.out.println("The second matrix is: \r\n" + Arrays.deepToString(tempSecondMatrix));int[][] tempThirdMatrix = multiplication(tempFirstMatrix, tempSecondMatrix);System.out.println("The third matrix is: \r\n" + Arrays.deepToString(tempThirdMatrix));System.out.println("Trying to multiply the first matrix with itself.\r\n");tempThirdMatrix = multiplication(tempFirstMatrix, tempFirstMatrix);System.out.println("The result matrix is: \r\n" + Arrays.deepToString(tempThirdMatrix));}
}

在这里插入图片描述

day9 while 语句

代码

还有一种循环是 do…while,其循环至少要执行一次循环体,而for和while循环需要先判断条件是否成立 在决定是否执行循环语句

package basic;public class WhileStatement {public static void main(String[] args) {whileStatementTest();}/*** The sum not exceeding a given value.*/public static void whileStatementTest() {int tempMax = 100;int tempValue = 0;int tempSum = 0;// Approach 1.while (tempSum <= tempMax) {tempValue++;tempSum += tempValue;System.out.println("tempValue = " + tempValue + ", tempSum = " + tempSum);}tempSum -= tempValue;System.out.println("The sum not exceeding " + tempMax + " is: " + tempSum);// Approach 2.System.out.println("\r\nAlternative approach.");tempValue = 0;tempSum = 0;while (true) {tempValue++;tempSum += tempValue;System.out.println("tempValue = " + tempValue + ", tempSum = " + tempSum);if (tempMax < tempSum) {break;}}tempSum -= tempValue;System.out.println("The sum not exceeding " + tempMax + " is: " + tempSum);}
}

在这里插入图片描述
在这里插入图片描述

day10 综合任务 1

10.1 题目解读

学生的成绩存放于一个矩阵,其中行表示学生,列表示科目。如:第 0 行表示第 0 个学生的数学、语文、英语成绩。要求:进行学生成绩的随机生成, 区间为 [50, 100];找出成绩最好、最差的同学。但有挂科的同学不参加评比.

  • 1.初始化学生成绩(会涉及到随机生成数据的区间范围:Random)
  • 2.通过for循环来计算学生总成绩并排除挂科同学(借助:break,continue关键字)
  • 3.for循环+if判断来找出成绩最好和最差的学生

10.2 代码

package basic;import java.util.Arrays;
import java.util.Random;
public class Task1 {public static void main(String[] args) {task1();}public static void task1(){//step1:Generate the data with n students and m courses.int n = 10;int m = 3;int lowerBound = 50;int upperBound = 100;int threshold = 60;// Here we have to use an object to generate random numbers.Random tempRandom = new Random();int[][] data = new int[n][m];for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {data[i][j] = lowerBound + tempRandom.nextInt(upperBound - lowerBound);}}System.out.println("The data is:\r\n" + Arrays.deepToString(data));// Step 2. Compute the total score of each student.int[] totalScores = new int[n];for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {if (data[i][j] < threshold) {totalScores[i] = 0;break;}totalScores[i] += data[i][j];}}System.out.println("The total scores are:\r\n" + Arrays.toString(totalScores));// Step 3. Find the best and worst student.// Typical initialization for index: invalid value.int tempBestIndex = -1;int tempWorstIndex = -1;// Typical initialization for best and worst values.// They must be replaced by valid values.int tempBestScore = 0;int tempWorstScore = m * upperBound + 1;for (int i = 0; i < n; i++) {// Do not consider failed students.if (totalScores[i] == 0) {continue;}if (tempBestScore < totalScores[i]) {tempBestScore = totalScores[i];tempBestIndex = i;}// Attention: This if statement cannot be combined with the last one using "else if", because a student can be both the best and the// worst. I found this bug while setting upperBound = 65.if (tempWorstScore > totalScores[i]) {tempWorstScore = totalScores[i];tempWorstIndex = i;}}// Step 4. Output the student number and score.if (tempBestIndex == -1) {System.out.println("Cannot find best student. All students have failed.");} else {System.out.println("The best student is No." + tempBestIndex + " with scores: "+ Arrays.toString(data[tempBestIndex]));}if (tempWorstIndex == -1) {System.out.println("Cannot find worst student. All students have failed.");} else {System.out.println("The worst student is No." + tempWorstIndex + " with scores: "+ Arrays.toString(data[tempWorstIndex]));}}
}

在这里插入图片描述

自我小结

三大结构

不管在c或者java,都会涉及到三大结构:顺序结构,选择结构,分支结构;通过对这三大结构的组合使用就可以解决一些很复杂的问题。
(1) 顺序结构:即按照代码的书写顺序依次执行,不存在跳转或者判断

  • 要避免代码冗余,可以通过封装相应的方法或类来避免;例如day4中我们可以专门封装一个方法来判断是否为闰年,而避免每次都去重复写来判断
  • 需要注意变量的使用范围等。例如day4中main方法中变量tempYear,正因为代码会顺序执行,所以可以对tempYear多次赋值从而覆盖前面的值。

(2)选择结构:会根据指定的判定条件去执行不同的代码块内容,如在day3,day4:if结构;if-else结构;if-else if结构;day5:switch结构

  • 在选择结构中,要保证我们的判定条件是正确的

(3)循环结构:会根据指定的条件重复执行一段代码块内容,直到条件不符合跳出循环,如在day6-9中 for循环,while循环,除此之外还有do…while循环

  • 循环条件要保证条件是能正确跳出循环条件的,否则会导致程序进入死循环

相关文章:

日撸 Java 三百行day1-10

文章目录说明day1 环境搭建1.1 开发环境1.2 package import 和 println1.3 编写HelloWorld.javaday2 基本算术操作2.1 加、减、乘、除、整除、取余.day3 基本if 语句3.1 if条件分支语句3.2 代码day4 闰年的计算4.1 思路整理&#xff1a;何为闰年&#xff1f;4.2 核心代码day5 基…...

Ubuntu Instant-ngp 训练自有数据集

1. 运行环境配置 conda create -n instant-ngp python3.10 conda activate instant-ngp pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple2. COLMAP稀疏重建生成transform.json colmap 环境配置参考文档&#xff1b; 终端定位在instant-ngp/da…...

k8s集群只一台节点,重启节点后命名空间找不到了

定位 如果您的Kubernetes集群只有一台节点&#xff0c;并且在重启节点之前您创建了一些命名空间和资源&#xff0c;那么在节点重启后&#xff0c;这些命名空间和资源可能会丢失。这是因为在Kubernetes中&#xff0c;资源和命名空间通常是存储在etcd中的。当节点重启时&#xf…...

MarkDown示例

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题&#xff0c;有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注…...

spring cloud 雪崩效应

什么是雪崩效应 雪崩就是塌方。在山坡上的积雪&#xff0c;如果积雪的内聚力小于重力或其他力量&#xff0c;则积雪便向下滑动&#xff0c;从而逐渐引起积雪的崩塌。 在微服务架构中&#xff0c;服务之间通常存在级联调用。比如&#xff0c;服务A调用服务B&#xff0c;而服…...

Python 自动化指南(繁琐工作自动化)第二版:三、函数

原文&#xff1a;https://automatetheboringstuff.com/2e/chapter3/ 您已经熟悉了前几章中的print()、input()和len()函数。Python 提供了几个这样的内置函数&#xff0c;但是您也可以编写自己的函数。函数就像一个程序中的一个小程序。 为了更好地理解函数是如何工作的&#…...

c++多线程 1

https://www.runoob.com/cplusplus/cpp-multithreading.html 两种类型的多任务处理&#xff1a;基于进程和基于线程。 基于进程的多任务处理是程序的并发执行。 基于线程的多任务处理是同一程序的片段的并发执行。 线程 c11以后有了 标准库 1 函数 2 类成员函数 3 lambda函…...

STM32F103制作FlashDriver

文章目录前言芯片内存定义实现过程FlashDriver生成段定义擦除函数写入函数编译后的map手动测试HexView提取指定地址内容并重映射总结前言 在汽车行业控制器软件刷新流程中&#xff0c;一般会将Flash驱动单独进行刷写&#xff0c;目的是防止程序中一直存在Flash驱动的话&#x…...

springboot树形结构接口, 懒加载实现

数据库关系有父子id的, 作为菜单栏展示时需要用前端需要用到懒加载, 所谓懒加载就是接口有一个标志位isLeaf, 前端请求后通过该字段判断该节点是否还有子节点数据 创建数据库表 t_company_info结构有id和parentId标识, 用来表示父子关系 /*Navicat Premium Data TransferSourc…...

java企业级信息系统开发学习笔记02初探spring——利用组件注解符精简spring配置文件

文章目录一、学习目标二、打开01的项目三、利用组件注解符精简spring配置文件&#xff08;一&#xff09;创建新包&#xff0c;复制四个类&#xff08;二&#xff09;修改杀龙任务类&#xff08;三&#xff09;修改救美任务类&#xff08;四&#xff09;修改勇敢骑士类&#xf…...

用Python发送电子邮件?这也太丝滑了吧(21)

小朋友们好&#xff0c;大朋友们好&#xff01; 我是猫妹&#xff0c;一名爱上Python编程的小学生。 欢迎和猫妹一起&#xff0c;趣味学Python。 今日主题 猫爸赚钱养家&#xff0c;细想起来真的不容易啊&#xff01; 起早贪黑&#xff0c;都是6点早起做早饭&#xff0c;送…...

分类预测 | MATLAB实现CNN-GRU-Attention多输入分类预测

分类预测 | MATLAB实现CNN-GRU-Attention多输入分类预测 目录分类预测 | MATLAB实现CNN-GRU-Attention多输入分类预测分类效果模型描述程序设计参考资料分类效果 模型描述 Matlab实现CNN-GRU-Attention多变量分类预测 1.data为数据集&#xff0c;格式为excel&#xff0c;12个输…...

C++提高编程(1)

C提高编程1.模板1.1模板的概念1.2函数模板1.2.1函数模板语法1.2.2函数模板注意事项1.2.3函数模板案例1.2.4普通函数与函数模板的区别1.2.5普通函数与函数模板的调用规则1.2.6模板的局限性1.3类模板1.3.1类模板语法1.3.2类模板和函数模板区别1.3.3类模板中成员函数创建时机1.3.4…...

day26 回溯算法的部分总结

回溯算法的部分总结 回溯算法是一种常用于解决排列组合问题、搜索问题的算法&#xff0c;它的基本思想是将问题的解空间转化为一棵树&#xff0c;通过深度优先搜索的方式遍历树上的所有节点&#xff0c;找到符合条件的解。回溯算法通常使用递归实现&#xff0c;每次递归时传入…...

带你玩转Python爬虫(胆小者勿进)千万别做坏事·······

这节课很危险&#xff0c;哈哈哈哈&#xff0c;逗你们玩的 目录 写在前面 1 了解robots.txt 1.1 基础理解 1.2 使用robots.txt 2 Cookie 2.1 两种cookie处理方式 3 常用爬虫方法 3.1 bs4 3.1.1 基础介绍 3.1.2 bs4使用 3.1.2 使用例子 3.2 xpath 3.2.1 xpath基础介…...

【JavaScript 】严格模式,With关键字,测试框架介绍,assert

❤️ Author&#xff1a; 老九 ☕️ 个人博客&#xff1a;老九的CSDN博客 &#x1f64f; 个人名言&#xff1a;不可控之事 乐观面对 &#x1f60d; 系列专栏&#xff1a; 文章目录静态类型语言弱类型严格模式将过失错误转化为异常简化变量的使用With测试框架try-catch选择性捕获…...

mybatis实现一个简单的CRUD功能的小案例(后端)编写流程

下面是一个使用mybatis实现增删改查功能的示例程序&#xff1a; 1.创建一个数据库 首先需要创建一个名为test_db的数据库&#xff0c;里面包含一个名为user_info的表&#xff0c;其中包含id、name、age三个字段。 2.配置mybatis 在项目的pom.xml文件中添加mybatis和mysql依…...

腾讯云轻量应用服务器价格表(2023版)

2023腾讯云轻量应用服务器2核2G4M带宽88元一年、2核4G6M带宽159元/年、4核8G10M优惠价425元、8核16G14M价格1249、16核32G20M服务器2499元一年&#xff0c;今天分享2023腾讯云服务器配置及精准报价。 腾讯云轻量应用服务器优惠价格表 腾讯云服务器分为轻量应用服务器和云服务器…...

网络层IP协议和数据链路层

目录IP协议协议头格式分片网段划分特殊的IP地址IP地址的数量限制NAT技术NAT技术背景NAT IP转换过程NAPTNAT技术的缺陷NAT和代理服务器私有IP地址和公网IP地址路由路由表生成算法数据链路层认识以太网以太网帧格式认识MAC地址对比理解MAC地址和IP地址认识MTUMTU对IP协议的影响MT…...

零基础学习Java 03

目录 数组 动态初始化数组 静态初始化 数组的应用 数组两种典型的异常 length关键字求出数组的长度 数组遍历在IDEA中输出快捷语句 对象数组 数组的遍历&#xff1a;foreach方法 二维数组 枚举(enum) 数组 1在方法中可以返回一个数组&#xff0c;但是在定义方法时类型要…...

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…...

51c自动驾驶~合集58

我自己的原文哦~ https://blog.51cto.com/whaosoft/13967107 #CCA-Attention 全局池化局部保留&#xff0c;CCA-Attention为LLM长文本建模带来突破性进展 琶洲实验室、华南理工大学联合推出关键上下文感知注意力机制&#xff08;CCA-Attention&#xff09;&#xff0c;…...

相机Camera日志实例分析之二:相机Camx【专业模式开启直方图拍照】单帧流程日志详解

【关注我&#xff0c;后续持续新增专题博文&#xff0c;谢谢&#xff01;&#xff01;&#xff01;】 上一篇我们讲了&#xff1a; 这一篇我们开始讲&#xff1a; 目录 一、场景操作步骤 二、日志基础关键字分级如下 三、场景日志如下&#xff1a; 一、场景操作步骤 操作步…...

基于Flask实现的医疗保险欺诈识别监测模型

基于Flask实现的医疗保险欺诈识别监测模型 项目截图 项目简介 社会医疗保险是国家通过立法形式强制实施&#xff0c;由雇主和个人按一定比例缴纳保险费&#xff0c;建立社会医疗保险基金&#xff0c;支付雇员医疗费用的一种医疗保险制度&#xff0c; 它是促进社会文明和进步的…...

转转集团旗下首家二手多品类循环仓店“超级转转”开业

6月9日&#xff0c;国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解&#xff0c;“超级…...

拉力测试cuda pytorch 把 4070显卡拉满

import torch import timedef stress_test_gpu(matrix_size16384, duration300):"""对GPU进行压力测试&#xff0c;通过持续的矩阵乘法来最大化GPU利用率参数:matrix_size: 矩阵维度大小&#xff0c;增大可提高计算复杂度duration: 测试持续时间&#xff08;秒&…...

自然语言处理——Transformer

自然语言处理——Transformer 自注意力机制多头注意力机制Transformer 虽然循环神经网络可以对具有序列特性的数据非常有效&#xff0c;它能挖掘数据中的时序信息以及语义信息&#xff0c;但是它有一个很大的缺陷——很难并行化。 我们可以考虑用CNN来替代RNN&#xff0c;但是…...

mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包

文章目录 现象&#xff1a;mysql已经安装&#xff0c;但是通过rpm -q 没有找mysql相关的已安装包遇到 rpm 命令找不到已经安装的 MySQL 包时&#xff0c;可能是因为以下几个原因&#xff1a;1.MySQL 不是通过 RPM 包安装的2.RPM 数据库损坏3.使用了不同的包名或路径4.使用其他包…...

tree 树组件大数据卡顿问题优化

问题背景 项目中有用到树组件用来做文件目录&#xff0c;但是由于这个树组件的节点越来越多&#xff0c;导致页面在滚动这个树组件的时候浏览器就很容易卡死。这种问题基本上都是因为dom节点太多&#xff0c;导致的浏览器卡顿&#xff0c;这里很明显就需要用到虚拟列表的技术&…...

安宝特案例丨Vuzix AR智能眼镜集成专业软件,助力卢森堡医院药房转型,赢得辉瑞创新奖

在Vuzix M400 AR智能眼镜的助力下&#xff0c;卢森堡罗伯特舒曼医院&#xff08;the Robert Schuman Hospitals, HRS&#xff09;凭借在无菌制剂生产流程中引入增强现实技术&#xff08;AR&#xff09;创新项目&#xff0c;荣获了2024年6月7日由卢森堡医院药剂师协会&#xff0…...