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

linux shell 入门学习笔记14 shell脚本+数学计算

概念

把复杂的命令执行过程,通过逻辑代码,组成一个脚本文件的方式就叫做shell脚本。

shebang

#! /bin/bash
#! /bin/perl
#! /bin/python

执行脚本的方式

source my_first.sh
. my_first.shbash my_first.sh
./my_first.sh

变量引用
${var} 取出变量结果
$() 在括号中执行命令,且拿到命令的执行结果
`` 在括号中执行命令,且拿到命令的执行结果
$var 取出变量结果
() 开启子shell执行命令

xiao123@xiao123:~/Downloads/shscripts$ echo "当前用户是:$(whoami)"
当前用户是:xiao123
xiao123@xiao123:~/Downloads/shscripts$ echo "当前用户是:`whoami`"
当前用户是:xiao123
xiao123@xiao123:~/Downloads/shscripts$ var=xiao123
xiao123@xiao123:~/Downloads/shscripts$ echo "当前用户是:${var}"
当前用户是:xiao123
xiao123@xiao123:~/Downloads/shscripts$ echo "当前用户是:$var"
当前用户是:xiao123
xiao123@xiao123:~/Downloads/shscripts$

数学计算

支持的运算符展示
数学计算1

Linux用于计算的命令展示
shell基础命令只支持整数,小数运算需要使用bc命令
运算命令

双小括号(())

用法
(())用法
演示:

xiao123@xiao123:~/Downloads/shscripts$ echo $((5<7))   #为True,1
1
xiao123@xiao123:~/Downloads/shscripts$ echo $((5>7))   #为Fase,0
0
xiao123@xiao123:~/Downloads/shscripts$

脚本开发

1.想好脚本的功能,作用,以及需求
2.转换为shell代码

开发一个,接收用户输入数字,且对运算符号判断,最终的出结果的一个计算脚本

  1. 接收用户输入
  2. 对用户输入的不是数字进行判断
  3. 对输入的运算符进行判断
  4. 最终进行结果计算,输出打印

代码

xiao123@xiao123:~/Downloads/shscripts$ cat ./calculation.sh
#! /bin/bashdo_usage() {printf "Please input an integer!!!\n"exit 1
}read -p "Please input first number: " firstif [ -n "`echo ${first}|sed 's/[0-9]//g'`" ];
thendo_usage
firead -p "Please input an operator: " operatorif [ ${operator} != '+' ] && [ ${operator} != '-' ] && [ ${operator} != '/' ] && [ ${operator} != '*' ];
thenecho "Please input [+/-/*//]!!!"exit 2
firead -p "Please input second number: " secondif [ -n "`echo ${second}|sed 's/[0-9]//g'`" ];
thendo_usage
fiecho "${first}${operator}${second}=" $((${first}${operator}${second}))
xiao123@xiao123:~/Downloads/shscripts$

运行结果

xiao123@xiao123:~/Downloads/shscripts$ ./calculation.sh
Please input first number: qew123
Please input an integer!!!
xiao123@xiao123:~/Downloads/shscripts$ ./calculation.sh
Please input first number: 123
Please input an operator: eeee
Please input [+/-/*//]!!!
xiao123@xiao123:~/Downloads/shscripts$ ./calculation.sh
Please input first number: 123
Please input an operator: +
Please input second number: 12
123+12= 135
xiao123@xiao123:~/Downloads/shscripts$

let命令运算

let命令的执行,效果等同于双小括号(())
但是,双小括号(())效率更高

#对比
xiao123@xiao123:~/Downloads/shscripts$ num=5
xiao123@xiao123:~/Downloads/shscripts$ num=num+5
xiao123@xiao123:~/Downloads/shscripts$ echo ${num}
num+5
xiao123@xiao123:~/Downloads/shscripts$ num=5+5
xiao123@xiao123:~/Downloads/shscripts$ echo ${num}
5+5
xiao123@xiao123:~/Downloads/shscripts$
#let命令
xiao123@xiao123:~/Downloads/shscripts$ num=5
xiao123@xiao123:~/Downloads/shscripts$ let num=num+5
xiao123@xiao123:~/Downloads/shscripts$ echo ${num}
10
xiao123@xiao123:~/Downloads/shscripts$ let num=5+5
xiao123@xiao123:~/Downloads/shscripts$ echo ${num}
10
xiao123@xiao123:~/Downloads/shscripts$

脚本开发,对于nginx运行状态检测

#! /bin/bashCheckUrl(){timeout=5fails=0success=0while truedowget --timeout=${timeout} --tries=1 http://www.baidu.com -q -o /dev/nullif [ $? -ne 0 ];thenlet fails=fails+1elselet success=success+1fiif [ ${success} -ge 1 ];thenecho "恭喜你,服务运行正常"exit 0fiif [ ${fails} -ge 2 ];thenecho "糟糕了,服务运行异常,请检查服务器状态"exit 2fidone
}CheckUrl# 运行结果
xiao123@xiao123:~/Downloads/shscripts$ ./let_test.sh
恭喜你,服务运行正常
xiao123@xiao123:~/Downloads/shscripts$

expr命令

简单的计算器执行命令。

xiao123@xiao123:~/Downloads/shscripts$ expr --help
Usage: expr EXPRESSIONor:  expr OPTION--help     display this help and exit--version  output version information and exitPrint the value of EXPRESSION to standard output.  A blank line below
separates increasing precedence groups.  EXPRESSION may be:ARG1 | ARG2       ARG1 if it is neither null nor 0, otherwise ARG2ARG1 & ARG2       ARG1 if neither argument is null or 0, otherwise 0ARG1 < ARG2       ARG1 is less than ARG2ARG1 <= ARG2      ARG1 is less than or equal to ARG2ARG1 = ARG2       ARG1 is equal to ARG2ARG1 != ARG2      ARG1 is unequal to ARG2ARG1 >= ARG2      ARG1 is greater than or equal to ARG2ARG1 > ARG2       ARG1 is greater than ARG2ARG1 + ARG2       arithmetic sum of ARG1 and ARG2ARG1 - ARG2       arithmetic difference of ARG1 and ARG2ARG1 * ARG2       arithmetic product of ARG1 and ARG2ARG1 / ARG2       arithmetic quotient of ARG1 divided by ARG2ARG1 % ARG2       arithmetic remainder of ARG1 divided by ARG2STRING : REGEXP   anchored pattern match of REGEXP in STRINGmatch STRING REGEXP        same as STRING : REGEXPsubstr STRING POS LENGTH   substring of STRING, POS counted from 1index STRING CHARS         index in STRING where any CHARS is found, or 0length STRING              length of STRING+ TOKEN                    interpret TOKEN as a string, even if it is akeyword like 'match' or an operator like '/'( EXPRESSION )             value of EXPRESSIONBeware that many operators need to be escaped or quoted for shells.
Comparisons are arithmetic if both ARGs are numbers, else lexicographical.
Pattern matches return the string matched between \( and \) or null; if
\( and \) are not used, they return the number of characters matched or 0.Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null
or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/expr>
or available locally via: info '(coreutils) expr invocation'
xiao123@xiao123:~/Downloads/shscripts$

实践
运算

expr 命令并不是很好用,基于空格传输参数,但是在shell中一些元字符都是有特殊含义的。
xiao123@xiao123:~/Downloads/shscripts$ expr 5 \+ 3
8
xiao123@xiao123:~/Downloads/shscripts$ expr 5 \- 3
2
xiao123@xiao123:~/Downloads/shscripts$ expr 5 \* 3
15
xiao123@xiao123:~/Downloads/shscripts$ expr 5 \/ 3
1
xiao123@xiao123:~/Downloads/shscripts$

求长度

xiao123@xiao123:~/Downloads/shscripts$ expr length 123456789
9
xiao123@xiao123:~/Downloads/shscripts$

逻辑运算

xiao123@xiao123:~/Downloads/shscripts$ expr 5 \> 6
0
xiao123@xiao123:~/Downloads/shscripts$ expr 5 \< 6
1
xiao123@xiao123:~/Downloads/shscripts$

模式匹配
2个特殊符号:

  • : 冒号,计算字符串字符的数量,Yuchao 6个字符
  • .* 任意字符重复0次或者多次

语法
expr 字符串 “:” “.*”

xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" ".*"
6
xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" ".*"  #统计文件中字符个数
6
xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" ".*j"  #最后的模式可以自定义
0
xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" "p.*"  #最后的模式可以自定义
0
xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" "y.*"  #最后的模式可以自定义
6
xiao123@xiao123:~/Downloads/shscripts$ expr yc.png ":" ".*p"  #最后的模式可以自定义
4
xiao123@xiao123:~/Downloads/shscripts$

脚本开发
需求:执行脚本,传入一个文件名,然后判断该文件,是否是jpg图片文件

xiao123@xiao123:~/Downloads/shscripts$ ./expr_test.sh chaochao_1.jpg
这的确是chaochao_1.jpg结尾的文件
xiao123@xiao123:~/Downloads/shscripts$ cat ./expr_test.sh
#! /bin/bashif expr "$1" ":" ".*\.jpg" >> /dev/nullthenecho "这的确是$1结尾的文件"
elseecho "这不是jpg结尾的文件"
fi
xiao123@xiao123:~/Downloads/shscripts$

找出长度不大于为5的单词

xiao123@xiao123:~/Downloads/shscripts$ ./expr_test1.sh
I
am
Yu
I
you
to
xiao123@xiao123:~/Downloads/shscripts$ cat ./expr_test1.sh
#! /bin/bashfor str1 in I am Yu chao, I teach you to learn linux.doif [ `expr length ${str1}` -lt 5 ]thenecho ${str1}fidone
xiao123@xiao123:~/Downloads/shscripts$

bc 命令

bc计算器
awk支持数值计算
中括号运算

bc当作计算器来用的,命令行的计算器。
例子1

xiao123@xiao123:~/Downloads/shscripts$ bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
2+2
4
4*4
16
1-1
0
1-2
-1
2.24/2
1
2.2/2.0
1
2.22-1.1
1.12
^C
(interrupt) use quit to exit.
exit
0
^C
(interrupt) use quit to exit.
quit
xiao123@xiao123:~/Downloads/shscripts$

例子2

xiao123@xiao123:~/Downloads/shscripts$ num=5
xiao123@xiao123:~/Downloads/shscripts$ echo ${num}*5 | bc
25
xiao123@xiao123:~/Downloads/shscripts$

案例

计算出1-1000的总和
数学公式
1+2+3+4+…+100

xiao123@xiao123:~/Downloads/shscripts$ echo {1..100}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
xiao123@xiao123:~/Downloads/shscripts$ #tr 替换
xiao123@xiao123:~/Downloads/shscripts$ echo {1..100} | tr " " "+" #方案1
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100
xiao123@xiao123:~/Downloads/shscripts$ seq -s "+" 100  #方案2
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100
xiao123@xiao123:~/Downloads/shscripts$
xiao123@xiao123:~/Downloads/shscripts$ echo {1..100} | tr " " "+" | bc
5050
xiao123@xiao123:~/Downloads/shscripts$
xiao123@xiao123:~/Downloads/shscripts$ echo $((`echo {1..100} | tr " " "+"`))
5050
xiao123@xiao123:~/Downloads/shscripts$
xiao123@xiao123:~/Downloads/shscripts$ seq -s " + " 100 | xargs expr
5050
xiao123@xiao123:~/Downloads/shscripts$

awk计算

awk支持小数计算。

xiao123@xiao123:~/Downloads/shscripts$ seq -s " + " 100 | xargs expr
5050
xiao123@xiao123:~/Downloads/shscripts$ echo "2.2" "3.0" | awk '{print $1*$2}'
6.6
xiao123@xiao123:~/Downloads/shscripts$ echo "2.2" "3.0" | awk '{print ($1*$2)}'
6.6
xiao123@xiao123:~/Downloads/shscripts$ echo "2.2" "3.0" | awk '{print ($1*$2)+4}'
10.6
xiao123@xiao123:~/Downloads/shscripts$ echo "2.2" "3.0" | awk '{print $1*$2+4}'
10.6
xiao123@xiao123:~/Downloads/shscripts$

中括号计算

$[表达式]

xiao123@xiao123:~/Downloads/shscripts$ num=5
xiao123@xiao123:~/Downloads/shscripts$ res=$[num+4]
xiao123@xiao123:~/Downloads/shscripts$ echo ${res}
9
xiao123@xiao123:~/Downloads/shscripts$ res=$[num-4]
xiao123@xiao123:~/Downloads/shscripts$ echo ${res}
1
xiao123@xiao123:~/Downloads/shscripts$ res=$[num*4]
xiao123@xiao123:~/Downloads/shscripts$ echo ${res}
20
xiao123@xiao123:~/Downloads/shscripts$ res=$[num/4]
xiao123@xiao123:~/Downloads/shscripts$ echo ${res}
1
xiao123@xiao123:~/Downloads/shscripts$

相关文章:

linux shell 入门学习笔记14 shell脚本+数学计算

概念 把复杂的命令执行过程&#xff0c;通过逻辑代码&#xff0c;组成一个脚本文件的方式就叫做shell脚本。 shebang #! /bin/bash #! /bin/perl #! /bin/python执行脚本的方式 source my_first.sh . my_first.shbash my_first.sh ./my_first.sh变量引用 ${var} 取出变量结果 …...

ESP32设备驱动-MAX30100心率监测传感器驱动

MAX30100心率监测传感器驱动 1、MAX30100介绍 MAX30100 是一款集成脉搏血氧饱和度和心率监测传感器解决方案。 它结合了两个 LED、一个光电探测器、优化的光学器件和低噪声模拟信号处理,以检测脉搏血氧饱和度和心率信号。 MAX30100 采用 1.8V 和 3.3V 电源供电,可通过软件…...

RTD2169芯片停产|完美替代RTD2169芯片|CS5260低BOM成本替代RTD2169方案设计

RTD2169芯片停产|完美替代RTD2169芯片|CS5260低BOM成本替代RTD2169方案设计 瑞昱的RTD2169芯片目前已经停产了&#xff0c; 那么之前用RTD2169来设计TYPEC转VGA方案的产品&#xff0c;该如何生产这类产品&#xff1f;且RTD2169芯片价格较贵&#xff0c;芯片封装尺寸是QFN40&…...

urho3d数据库

只有在启用以下两个构建选项之一时&#xff0c;数据库子系统才会构建到Urho3D库中&#xff1a;Urho3D_Database_ODBC和Urho3D-Database_SQLITE。当两个选项都启用时&#xff0c;URHO3D_DATABASE_ODBC优先。这些构建选项决定子系统将使用哪个数据库API。ODBC DB API更适用于本地…...

141. 周期

Powered by:NEFU AB-IN Link 文章目录141. 周期题意思路代码141. 周期 题意 一个字符串的前缀是从第一个字符开始的连续若干个字符&#xff0c;例如 abaab 共有 5个前缀&#xff0c;分别是 a&#xff0c;ab&#xff0c;aba&#xff0c;abaa&#xff0c;abaab。 我们希望知道一…...

Windows下命令执行绕过技巧总结(渗透测试专用)

一、连接符1、双引号不要求双引号闭合举例&#xff1a;"who"a"mi" //闭合的 "who"a"mi //不闭合的2、圆括号必须在两边&#xff0c;不能包括中间的字符。举例&#xff1a;((whoami))3、^符号&#xff08;转译符号&#xff09;不可以在结尾&…...

mindspore的MLP模型(多层感知机)

导入模块 import hashlib import os import tarfile import zipfile import requests import numpy as np import pandas as pd import mindspore import mindspore.dataset as ds from mindspore import nn import mindspore.ops as ops import mindspore.numpy as mnp from …...

【论文极速读】VQ-VAE:一种稀疏表征学习方法

【论文极速读】VQ-VAE&#xff1a;一种稀疏表征学习方法 FesianXu 20221208 at Baidu Search Team 前言 最近有需求对特征进行稀疏编码&#xff0c;看到一篇论文VQ-VAE&#xff0c;简单进行笔记下。如有谬误请联系指出&#xff0c;本文遵循 CC 4.0 BY-SA 版权协议&#xff0c;…...

Flask-Blueprint

Flask-Blueprint 一、简介 概念&#xff1a; Blueprint 是一个存储操作方法的容器&#xff0c;这些操作在这个Blueprint 被注册到一个应用之后就可以被调用&#xff0c;Flask 可以通过Blueprint来组织URL以及处理请求 。 好处&#xff1a; 其本质上来说就是让程序更加松耦合…...

png图片转eps格式

下载latex工具后 在要转换的png图片文件夹路径下&#xff0c;打开命令行窗口&#xff0c;输入以下命令&#xff1a; bmeps -c fig图片名.png 图片名.eps...

English Learning - L2 语音作业打卡 Day2 2023.2.23 周四

English Learning - L2 语音作业打卡 Day2 2023.2.23 周四&#x1f48c; 发音小贴士&#xff1a;&#x1f48c; 当日目标音发音规则/技巧&#xff1a;&#x1f36d; Part 1【热身练习】&#x1f36d; Part2【练习内容】&#x1f36d;【练习感受】&#x1f353;元音[ ɔ: ]&…...

低频量化之 可转债 配债 策略数据 - 全网独家

目录历史文章可转债配债数据待发转债&#xff08;进展统计&#xff09;待发转债&#xff08;行业统计&#xff09;待发转债&#xff08;5证监会通过&#xff0c;PE排序&#xff09;待发转债&#xff08;5证监会通过&#xff0c;安全垫排序&#xff09;待发转债&#xff08;4发审…...

论文阅读_DALLE-2的unCLIP模型

论文信息 name_en: Hierarchical Text-Conditional Image Generation with CLIP Latents name_ch: 利用CLIP的层次化文本条件图像生成 paper_addr: http://arxiv.org/abs/2204.06125 doi: 10.48550/arXiv.2204.06125 date_read: 2023-02-12 date_publish: 2022-04-12 tags: [‘…...

软件测试5年,历经3轮面试成功拿下华为Offer,24K/16薪不过分吧

前言 转眼过去&#xff0c;距离读书的时候已经这么久了吗&#xff1f;&#xff0c;从18年5月本科毕业入职了一家小公司&#xff0c;到现在快5年了&#xff0c;前段时间社招想着找一个新的工作&#xff0c;前前后后花了一个多月的时间复习以及面试&#xff0c;前几天拿到了华为的…...

【软件工程】课程作业(三道题目:需求分析、概要设计、详细设计、软件测试)

文章目录&#xff1a;故事的开头总是极尽温柔&#xff0c;故事会一直温柔……&#x1f49c;一、你怎么理解需求分析&#xff1f;1、需求分析的定义&#xff1a;2、需求分析的重要性&#xff1a;3、需求分析的内容&#xff1a;4、基于系统分析的方法分类&#xff1a;5、需求分析…...

05 DC-AC逆变器(DCAC Converter / Inverter)简介

文章目录0、概述逆变原理方波变换阶梯波变换斩控调制方式逆变器分类逆变器波形指标1、方波变换器A 单相单相全桥对称单脉冲调制移相单脉冲调制单相半桥2、方波变换器B 三相180度导通120度导通&#xff08;线、相的关系与180度相反&#xff09;3、阶梯波逆变器独立直流源二极管钳…...

带你深层了解c语言指针

前言 &#x1f388;个人主页:&#x1f388; :✨✨✨初阶牛✨✨✨ &#x1f43b;推荐专栏: &#x1f354;&#x1f35f;&#x1f32f; c语言进阶 &#x1f511;个人信条: &#x1f335;知行合一 &#x1f349;本篇简介:>:介绍c语言中有关指针更深层的知识. 金句分享: ✨今天…...

2-MATLAB APP Design-下拉菜单栏的使用

一、APP 界面设计展示 1.新建一个空白的APP,在此次的学习中,我们会用到编辑字段(文本框)、下拉菜单栏、坐标区,首先在界面中拖入一个编辑字段(文本框),在文本框中输入内容:下拉菜单栏的使用,调整背景颜色,字体的颜色为黑色,字体的大小调为26. 2.在左侧组件库常用栏…...

七、HTTPTomcatServlet

1&#xff0c;Web概述 1.1 Web和JavaWeb的概念 Web是全球广域网&#xff0c;也称为万维网(www)&#xff0c;能够通过浏览器访问的网站。 在我们日常的生活中&#xff0c;经常会使用浏览器去访问百度、京东、传智官网等这些网站&#xff0c;这些网站统称为Web网站。如下就是通…...

LeetCode 热题 C++ 198. 打家劫舍

力扣198 你是一个专业的小偷&#xff0c;计划偷窃沿街的房屋。每间房内都藏有一定的现金&#xff0c;影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统&#xff0c;如果两间相邻的房屋在同一晚上被小偷闯入&#xff0c;系统会自动报警。 给定一个代表每个房屋存…...

C语言学习笔记——程序环境和预处理

目录 前言 一、程序环境 1. 翻译环境 1.1 主要过程 1.2 编译过程 2. 运行环境 二、预处理 1. 预定义符号 2. #define 2.1 #define定义标识符 2.2 #define定义宏 2.3 命名约定和移除定义 3. 条件编译 4. 文件包含 结束语 前言 每次我们写完代码运行的时候都…...

「JVM 高效并发」Java 内存模型

Amdahl 定律代替摩尔定律成为了计算机性能发展的新源动力&#xff0c;也是人类压榨计算机运算能力的最有力武器&#xff1b; 摩尔定律&#xff0c;描述处理器晶体管数量与运行效率之间的发展关系&#xff1b;Amdahl 定律&#xff0c;描述系统并行化与串行化的比重与系统运算加…...

C语言刷题(2)——“C”

各位CSDN的uu们你们好呀&#xff0c;今天小雅兰来复习一下之前所学过的内容噢&#xff0c;复习的方式&#xff0c;那当然是刷题啦&#xff0c;现在&#xff0c;就让我们进入C语言的世界吧 当然&#xff0c;题目还是来源于牛客网 完完全全零基础 编程语言初学训练营_在线编程题…...

第一个 Spring MVC 注解式开发案例(初学必看)

✅作者简介&#xff1a;2022年博客新星 第八。热爱国学的Java后端开发者&#xff0c;修心和技术同步精进。 &#x1f34e;个人主页&#xff1a;Java Fans的博客 &#x1f34a;个人信条&#xff1a;不迁怒&#xff0c;不贰过。小知识&#xff0c;大智慧。 &#x1f49e;当前专栏…...

openresty学习笔记

openresty 简介 openresty 是一个基于 nginx 与 lua 的高性能 web 平台&#xff0c;其内部 集成了大量精良的 lua 库、第三方模块以及大数的依赖项。用于 方便搭建能够处理超高并发、扩展性极高的动态 web 应用、 web 服务和动态网关。 openresty 通过汇聚各种设计精良的 ngi…...

微信小程序DAY3

文章目录一、页面导航1-1、声明式导航1-2、编程式导航1-3、声明式导航传参1-4、编程式导航传参1-5、获取导航传递的参数二、页面事件2-1、下拉刷新事件2-1-1、启用下拉刷新2-1-2、配置下拉刷新2-1-3、监听页面下拉刷新事件2-2、上拉触底事件2-2-1、事件触发2-2-1、事件配置三、…...

【CAN】手把手教你学习CAN总线(一)

CAN总线一、CAN总线概念二、CAN的差分信号三、CAN总线的通信协议1、 帧起始2、仲裁段3、控制段4、数据段5、CRC段6、ACK段7、帧结束四、CAN的位时序1、同步段&#xff08;SS&#xff09;2、传播时间段&#xff08;PTS&#xff09;3、相位缓冲段&#xff08;PBS&#xff09;4、再…...

JUC 体系的基石——AQS

—— AQS&#xff08;AbstractQueuedSynchronizer&#xff09; 概念 抽象队列同步器&#xff1b;volatile cas 机制实现的锁模板&#xff0c;保证了代码的同步性和可见性&#xff0c;而 AQS 封装了线程阻塞等待挂起&#xff0c;解锁唤醒其他线程的逻辑。AQS 子类只需要根据状…...

Qt中信号与槽的使用

Qt中信号与槽的使用 Qt当中一个重要的东西是信号和槽&#xff0c;它被用于对象之间的通信。 在Qt中&#xff0c;例如“点击按钮”这个事件就是发送信号的对象&#xff0c;接收信号的是某一个窗口&#xff0c;响应信号的是一个处理&#xff0c;可以是隐藏窗口或者是关闭窗口。…...

力扣-销售员

大家好&#xff0c;我是空空star&#xff0c;本篇带大家了解一道简单的力扣sql练习题。 文章目录前言一、题目&#xff1a;607. 销售员二、解题1.正确示范①提交SQL运行结果2.正确示范②提交SQL运行结果3.正确示范③提交SQL运行结果4.正确示范④提交SQL运行结果5.其他总结前言 …...