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

跟着 Lua 5.1 官方参考文档学习 Lua (11)

文章目录

      • 5.4.1 – Patterns
        • Character Class:
        • Pattern Item:
        • Pattern:
        • Captures:
      • `string.find (s, pattern [, init [, plain]])`
        • 例子:string.find 的简单使用
      • `string.match (s, pattern [, init])`
      • `string.gmatch (s, pattern)`
      • `string.gsub (s, pattern, repl [, n])`
          • 例子:计算包含的元音字母个数
          • 例子 :'*'和'-'的区别
    • 5.5 – Table Manipulation
      • `table.concat (table [, sep [, i [, j]]])`
      • `table.insert (table, [pos,] value)`
      • `table.maxn (table)`
      • `table.remove (table [, pos])`
      • `table.sort (table [, comp])`
    • 5.6 – Mathematical Functions

5.4.1 – Patterns

Character Class:

A character class is used to represent a set of characters. The following combinations are allowed in describing a character class:

  • x: (where x is not one of the magic characters ^$()%.[]*+-?) represents the character x itself.

  • .: (a dot) represents all characters.

  • %a: represents all letters.

  • %c: represents all control characters.

  • %d: represents all digits.

  • %l: represents all lowercase letters.

  • %p: represents all punctuation characters.

  • %s: represents all space characters.

  • %u: represents all uppercase letters.

  • %w: represents all alphanumeric characters.

  • %x: represents all hexadecimal digits.

  • %z: represents the character with representation 0.

  • %x: (where x is any non-alphanumeric character) represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a ‘%’ when used to represent itself in a pattern.

  • [set]: represents the class which is the union of all characters in set. A range of characters can be specified by separating the end characters of the range with a ‘-’. All classes %x described above can also be used as components in set. All other characters in set represent themselves.

    For example, [%w_] (or [_%w]) represents all alphanumeric characters plus the underscore,

    [0-7] represents the octal digits, and [0-7%l%-] represents the octal digits plus the lowercase letters plus the ‘-’ character.

    The interaction between ranges and classes is not defined. Therefore, patterns like [%a-z] or [a-%%] have no meaning.

  • [^set]: represents the complement of set, where set is interpreted as above.

For all classes represented by single letters (%a, %c, etc.), the corresponding uppercase letter represents the complement of the class. For instance, %S represents all non-space characters.

The definitions of letter, space, and other character groups depend on the current locale. In particular, the class [a-z] may not be equivalent to %l.

Pattern Item:

A pattern item can be

  • a single character class, which matches any single character in the class;
  • a single character class followed by ‘*’, which matches 0 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
  • a single character class followed by ‘+’, which matches 1 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
  • a single character class followed by ‘-’, which also matches 0 or more repetitions of characters in the class. Unlike ‘*’, these repetition items will always match the shortest possible sequence;
  • a single character class followed by ‘?’, which matches 0 or 1 occurrence of a character in the class;
  • %n, for n between 1 and 9; such item matches a substring equal to the n-th captured string (see below);
  • %bxy, where x and y are two distinct characters; such item matches strings that start with x, end with y, and where the x and y are balanced. This means that, if one reads the string from left to right, counting +1 for an x and -1 for a y, the ending y is the first y where the count reaches 0. For instance, the item %b() matches expressions with balanced parentheses.
Pattern:

A pattern is a sequence of pattern items.

A ‘^’ at the beginning of a pattern anchors the match at the beginning of the subject string.

A ‘$’ at the end of a pattern anchors the match at the end of the subject string.

At other positions, ‘^’ and ‘$’ have no special meaning and represent themselves.

Captures:

A pattern can contain sub-patterns enclosed in parentheses; they describe captures. When a match succeeds, the substrings of the subject string that match captures are stored (captured) for future use. Captures are numbered according to their left parentheses. For instance, in the pattern "(a*(.)%w(%s*))", the part of the string matching "a*(.)%w(%s*)" is stored as the first capture (and therefore has number 1); the character matching “.” is captured with number 2, and the part matching “%s*” has number 3.

As a special case, the empty capture () captures the current string position (a number). 【注意:() 的含义】For instance, if we apply the pattern "()aa()" on the string "flaaap", there will be two captures: 3 and 5.

A pattern cannot contain embedded zeros. Use %z instead.

string.find (s, pattern [, init [, plain]])

Looks for the first match of pattern in the string s. If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities【plain参数为true,那么就是普通的字符串查找】, so the function does a plain “find substring” operation, with no characters in pattern being considered “magic”. Note that if plain is given, then init must be given as well.

If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.

例子:string.find 的简单使用
s = "hello world"
i, j = string.find(s, "hello")
print(i, j)                    --> 1 5
print(string.sub(s, i, j))     --> hello
print(string.find(s, "world")) --> 7 11
i, j = string.find(s, "l")
print(i, j)                    --> 3 3
print(string.find(s, "lll"))   --> nils = "Deadline is 30/05/1999, firm"
date = "%d%d/%d%d/%d%d%d%d"
print(string.sub(s, string.find(s, date))) --> 30/05/1999

补充内容:

The string.find function has an optional third parameter: an index that tells where in the subject string to start the search. This parameter is useful when we want to process all the indices where a given pattern appears: we search for a new match repeatedly, each time starting after the position where we found the previous one. As an example, the following code makes a table with the positions of all newlines in a string:

local t = {} -- table to store the indices
local i = 0
while true doi = string.find(s, "\n", i + 1) -- find next newlineif i == nil then break endt[#t + 1] = i
end

For instance, the test

if string.find(s, "^%d") then ...

checks whether the string s starts with a digit, and the test

if string.find(s, "^[+-]?%d+$") then ...

checks whether this string represents an integer number, without other leading
or trailing characters.

string.match (s, pattern [, init])

Looks for the first match of pattern in the string s. If it finds one, then match returns the captures from the pattern; otherwise it returns nil. If pattern specifies no captures, then the whole match is returned. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative.

注意比较 match 函数和 find 函数返回值的不同!

find 函数返回字符串中第一个匹配 pattern 的子字符串的位置和 pattern 中所有的 captures。

match 函数返回字符串中第一个匹配 pattern 的子字符串中所有的 captures。

find 函数比 match 函数多返回第一个匹配 pattern 的子字符串的位置。

补充内容:

We can use captures in the pattern itself. In a pattern, an item like ‘%d’, where d is a single digit, matches only a copy of the d-th capture. As a typical use, suppose you want to find, inside a string, a substring enclosed between single or double quotes. You could try a pattern such as ‘[“’].-[”’]’, that is, a quote followed by anything followed by another quote; but you would have problems with strings like “it’s all right”. To solve this problem, you can capture the first quote and use it to specify the second one:

s = [[then he said: "it’s all right"!]]
q, quotedPart = string.match(s, "([\"’])(.-)%1")
print(quotedPart)     --> it’s all right
print(q)

A similar example is the pattern that matches long strings in Lua:

%[(=*)%[(.-)%]%1%]

It will match an opening square bracket followed by zero or more equal signs, followed by another opening square bracket, followed by anything (the string content), followed by a closing square bracket, followed by the same number of equal signs, followed by another closing square bracket:

p = "%[(=*)%[(.-)%]%1%]"
s = "a = [=[[[ something ]] ]==] ]=]; print(a)"
print(string.match(s, p)) --> = [[ something ]] ]==]

The first capture is the sequence of equal signs (only one in this example); the second is the string content

string.gmatch (s, pattern)

Returns an iterator function that, each time it is called, returns the next captures from pattern over string s. If pattern specifies no captures, then the whole match is produced in each call.

As an example, the following loop

     s = "hello world from Lua"for w in string.gmatch(s, "%a+") doprint(w)end

will iterate over all the words from string s, printing one per line. The next example collects all pairs key=value from the given string into a table:

     t = {}s = "from=world, to=Lua"for k, v in string.gmatch(s, "(%w+)=(%w+)") dot[k] = vend

For this function, a ‘^’ at the start of a pattern does not work as an anchor, as this would prevent the iteration.

string.gsub (s, pattern, repl [, n])

Returns a copy of s in which all (or the first n, if given) occurrences of the pattern have been replaced by a replacement string specified by repl, which can be a string, a table, or a function. gsub also returns, as its second value, the total number of matches that occurred.

If repl is a string, then its value is used for replacement. The character % works as an escape character: any sequence in repl of the form %n, with n between 1 and 9, stands for the value of the n-th captured substring (see below). The sequence %0 stands for the whole match. The sequence %% stands for a single %.

If repl is a table, then the table is queried for every match, using the first capture as the key; if the pattern specifies no captures, then the whole match is used as the key.

If repl is a function, then this function is called every time a match occurs, with all captured substrings passed as arguments, in order; if the pattern specifies no captures, then the whole match is passed as a sole argument.

If the value returned by the table query or by the function call is a string or a number, then it is used as the replacement string; otherwise, if it is false or nil, then there is no replacement (that is, the original match is kept in the string).

Here are some examples:

     x = string.gsub("hello world", "(%w+)", "%1 %1")--> x="hello hello world world"x = string.gsub("hello world", "%w+", "%0 %0", 1)--> x="hello hello world"x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")--> x="world hello Lua from"x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)--> x="home = /home/roberto, user = roberto"x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)return loadstring(s)()end)--> x="4+5 = 9"local t = {name="lua", version="5.1"}x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)--> x="lua-5.1.tar.gz"

补充内容:

例子:计算包含的元音字母个数
nvow = select(2, string.gsub(text, "[AEIOUaeiou]", ""))
例子 :'*‘和’-'的区别
test = "int x; /* x */ int y; /* y */"
print(string.gsub(test, "/%*.*%*/", "<COMMENT>")) --> int x; <COMMENT>   1test = "int x; /* x */ int y; /* y */"
print(string.gsub(test, "/%*.-%*/", "<COMMENT>")) --> int x; <COMMENT> int y; <COMMENT>    2

补充内容:

Another item in a pattern is ‘%b’, which matches balanced strings. Such item is written as ‘%bxy’, where x and y are any two distinct characters; the x acts as an opening character and the y as the closing one. For instance, the pattern ‘%b()’ matches parts of the string that start with a ‘(’ and finish at the respective ‘)’:

s = "a (enclosed (in) parentheses) line"
print(string.gsub(s, "%b()", "")) --> a line

Typically, this pattern is used as ‘%b()’, ‘%b[]’, ‘%b{}’, or ‘%b<>’, but you can use any characters as delimiters.

5.5 – Table Manipulation

This library provides generic functions for table manipulation. It provides all its functions inside the table table.

Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the “length” of a table we mean the result of the length operator.

table.concat (table [, sep [, i [, j]]])

Given an array where all elements are strings or numbers, returns table[i]..sep..table[i+1] ··· sep..table[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is the length of the table. If i is greater than j, returns the empty string.

table.insert (table, [pos,] value)

Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for pos is n+1, where n is the length of the table (see §2.5.5), so that a call table.insert(t,x) inserts x at the end of table t.

table.maxn (table)

Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. (To do its job this function does a linear traversal of the whole table.)

table.remove (table [, pos])

Removes from table the element at position pos, shifting down other elements to close the space, if necessary. Returns the value of the removed element. The default value for pos is n, where n is the length of the table, so that a call table.remove(t) removes the last element of table t.

table.sort (table [, comp])

Sorts table elements in a given order, in-place, from table[1] to table[n], where n is the length of the table. If comp is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.

The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort.

5.6 – Mathematical Functions

This library is an interface to the standard C math library. It provides all its functions inside the table math.

忽略

相关文章:

跟着 Lua 5.1 官方参考文档学习 Lua (11)

文章目录 5.4.1 – PatternsCharacter Class:Pattern Item:Pattern:Captures: string.find (s, pattern [, init [, plain]])例子&#xff1a;string.find 的简单使用 string.match (s, pattern [, init])string.gmatch (s, pattern)string.gsub (s, pattern, repl [, n])例子&…...

<script setup>和export default { setup() { ... } }区别

在 Vue 3 组合式 API&#xff08;Composition API&#xff09;中&#xff0c;<script setup> 和 export default setup() {} 都用于定义组件的逻辑&#xff0c;但它们有一些重要的区别&#xff1a; 1️⃣ <script setup>&#xff08;推荐&#xff09; ✅ 更简洁、…...

leetcode hot100--动态规划【五步总纲】

五步&#xff1a; 1.dp数组以及下标定义 dp[i] 2.递推公式 dp[n]dp[n-1]dp[n-2] 3.dp数组如何初始化 注意&#xff1a;判断边界条件&#xff0c;n0dp[1]就不存在【斐波那契】 4.遍历顺序 for循环顺序 5.打印数组【debug】 第一题&#xff1a;斐波那契数列 首先回顾了…...

RtlLookupAtomInAtomTable函数分析之RtlpAtomMapAtomToHandleEntry函数的作用是验证其正确性

第一部分&#xff1a; NTSTATUS RtlLookupAtomInAtomTable( IN PVOID AtomTableHandle, IN PWSTR AtomName, OUT PRTL_ATOM Atom OPTIONAL ) { NTSTATUS Status; PRTL_ATOM_TABLE p (PRTL_ATOM_TABLE)AtomTableHandle; PRTL_ATOM_TABLE_ENTRY a; …...

【从零开始学习计算机科学】硬件设计与FPGA原理

硬件设计 硬件设计流程 在设计硬件电路之前,首先要把大的框架和架构要搞清楚,这要求我们搞清楚要实现什么功能,然后找找有否能实现同样或相似功能的参考电路板(要懂得尽量利用他人的成果,越是有经验的工程师越会懂得借鉴他人的成果)。如果你找到了的参考设计,最好还是…...

todo: 使用融云imserve做登录(android)

使用融云做登录注册思路 注册界面需要name, email, password考虑到融云注册用户的post格式 POST http://api.rong-api.com/user/getToken.json?userId1690544550qqcom&nameIronman这里的userId可以使用用户的email&#xff0c;但是要截断和 . 符号&#xff0c;即1690544…...

从0开始的操作系统手搓教程23:构建输入子系统——实现键盘驱动1——热身驱动

目录 所以&#xff0c;键盘是如何工作的 说一说我们的8042 输出缓冲区寄存器 状态寄存器 控制寄存器 动手&#xff01; 注册中断 简单整个键盘驱动 Reference ScanCode Table 我们下一步就是准备进一步完善我们系统的交互性。基于这个&#xff0c;我们想到的第一个可以…...

Azure云生态系统详解:核心服务、混合架构与云原生概念

核心服务&#xff1a;深入掌握Azure SQL Database、Azure Database for PostgreSQL、Azure Database for MySQL的架构、备份恢复、高可用性配置&#xff08;如Geo-Replication、自动故障转移组、异地冗余备份&#xff09;。混合架构&#xff1a;熟悉Azure Arc&#xff08;管理混…...

Unity Dots

文章目录 什么是DotsDOTS的优势ECS&#xff08;实体组件系统&#xff09;Job System作业系统Burst编译器最后 什么是Dots DOTS&#xff08;Data-Oriented Technology Stack&#xff09;是Unity推出的一种用于开发高性能游戏和应用的数据导向技术栈&#xff0c;包含三大核心组件…...

SAP DOI EXCEL宏的使用

OAOR里上传EXCEL模版 屏幕初始化PBO创建DOI EXCEL对象&#xff0c;并填充EXCEL内容 *&---------------------------------------------------------------------* *& Module INIT_DOI_DISPLAY_9100 OUTPUT *&--------------------------------------------…...

VSTO(C#)Excel开发3:Range对象 处理列宽和行高

初级代码游戏的专栏介绍与文章目录-CSDN博客 我的github&#xff1a;codetoys&#xff0c;所有代码都将会位于ctfc库中。已经放入库中我会指出在库中的位置。 这些代码大部分以Linux为目标但部分代码是纯C的&#xff0c;可以在任何平台上使用。 源码指引&#xff1a;github源…...

单链表基本操作的实现与解析(补充)

目录 一、引言 二、代码实现 遍历考虑情况 三、操作解析 查找操作&#xff08;sltfind函数&#xff09; 前插操作&#xff08;sltinsert函数&#xff09; 后插操作&#xff08;sltinsertafter函数&#xff09; 前删操作&#xff08;slterase函数&#xff09; 后删操作&…...

电子学会—2024年月6青少年软件编程(图形化)四级等级考试真题——魔法门

魔法门 1.准备工作 (1)保留默认角色小猫和白色背景; (2)添加角色Home Button&#xff0c;复制9个造型&#xff0c;在每个造型上分别加上数字1到9&#xff0c;如下图所示; 2.功能实现 (1)程序开始&#xff0c;依次克隆出五个Home Button&#xff0c;克隆体之间的间距为90; …...

《加快应急机器人发展的指导意见》中智能化升级的思考——传统应急设备智能化升级路径与落地实践

感谢阅读本次内容分享&#xff0c;下面我将解读分析《加快应急机器人发展的指导意见》&#xff0c;喜欢的点赞支持一下呗~(日更真的很辛苦~)&#xff0c;欢迎评论区留言讨论&#xff0c;你们的发言我都会看到~ 《加快应急机器人发展的指导意见》中智能化升级的思考——传统应急…...

Git系列之git tag和ReleaseMilestone

以下是关于 Git Tag、Release 和 Milestone 的深度融合内容&#xff0c;并补充了关于 Git Tag 的所有命令、详细解释和指令实例&#xff0c;条理清晰&#xff0c;结合实际使用场景和案例。 1. Git Tag 1.1 定义 • Tag 是 Git 中用于标记特定提交&#xff08;commit&#xf…...

【每日学点HarmonyOS Next知识】Web上传文件、监听上下左右区域连续点击、折叠悬停、字符串相关、播放沙盒视频

1、HarmonyOS APP内h5原生webview input[typefile]无法唤醒手机上传&#xff1f; 文件上传要使用对应的picker https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/web-file-upload-V5 Web组件支持前端页面选择文件上传功能&#xff0c;应用开发者可以使用on…...

解决电脑问题(3)——显示器问题

当电脑显示器出现问题时&#xff0c;可以根据不同的故障现象采取相应的解决方法&#xff0c;以下是一些常见的情况及解决措施&#xff1a; 屏幕无显示 检查连接&#xff1a;首先检查显示器与电脑主机之间的视频连接线是否插好&#xff0c;确保两端的接口都牢固连接&#xff0c…...

AArch64架构及其编译器

—1.关于AArch64架构 AArch64是ARMv8-A架构的64位执行状态&#xff0c;支持高性能计算和大内存地址空间。它广泛应用于现代处理器&#xff0c;如苹果的A系列芯片、高通的Snapdragon系列&#xff0c;以及服务器和嵌入式设备。 • 编译器&#xff1a;可以使用GCC、Clang等编译器编…...

免费送源码:Java+springboot+MySQL 房屋租赁系统小程序的设计与实现 计算机毕业设计原创定制

目 录 摘要 1 1 绪论 1 1.1选题意义 1 1.2开发现状 1 1.3springboot框架介绍 1 1.4论文结构与章节安排 1 2 房屋租赁系统小程序系统分析 3 2.1 可行性分析 3 2.1.1 技术可行性分析 3 2.1.2 经济可行性分析 3 2.1.3 法律可行性分析 3 2.2 系统功能分析 3 2.2.1 功…...

前端数据模拟 Mock.js 学习笔记

mock.js介绍 Mock.js是一款前端开发中拦截Ajax请求再生成随机数据响应的工具&#xff0c;可以用来模拟服务器响应 优点是&#xff1a;非常方便简单&#xff0c;无侵入性&#xff0c;基本覆盖常用的接口数据类型支持生成随机的文本、数字、布尔值、日期、邮箱、链接、图片、颜…...

【Linux内核系列】:深入解析输出以及输入重定向

&#x1f525; 本文专栏&#xff1a;Linux &#x1f338;作者主页&#xff1a;努力努力再努力wz ★★★ 本文前置知识&#xff1a; 文件系统以及文件系统调用接口 用c语言简单实现一个shell外壳程序 内容回顾 那么在此前的学习中&#xff0c;我们对于Linux的文件系统已经有了…...

Adam 优化器与动量法:二阶矩与 ODE 的联系

Adam 优化器与动量法&#xff1a;二阶矩与 ODE 的联系 作为深度学习研究者&#xff0c;你一定对 Adam&#xff08;Adaptive Moment Estimation&#xff09;优化器非常熟悉。它因自适应学习率和高效率而成为训练神经网络的标配算法。Adam 使用了一阶动量&#xff08;梯度的指数…...

嵌入式学习第二十三天--网络及TCP

进程通信的方式: 同一主机 传统 system V 不同主机 网络 --- 解决不同主机间 的进程间通信 网络 (通信) //1.物理层面 --- 联通(通路) //卫星 2G 3G 4G 5G 星链 (千帆) //2.逻辑层面 --- 通路(软件) MAC os LINUX …...

前端表单提交与后端处理全解析:从HTML到Axios与SpringBoot实战

前端表单提交与后端处理全解析:从HTML到Axios与SpringBoot实战 一、GET与POST请求的两种面孔 1. HTML表单基础实现 <!-- GET请求示例:搜索表单 --> <form action="/api/search" method="GET"><input type="text" name="…...

python django orm websocket html 实现deepseek持续聊天对话页面

最终效果&#xff1a; 技术栈&#xff1a; python django orm websocket html 项目结构&#xff1a; 这里只展示关键代码&#xff1a; File: consumers.py # -*- coding:utf-8 -*- # Author: 喵酱 # time: 2025 - 03 -02 # File: consumers.py # desc: import json from asg…...

大白话html语义化标签优势与应用场景

大白话html语义化标签优势与应用场景 大白话解释 语义化标签就是那些名字能让人一看就大概知道它是用来做什么的标签。以前我们经常用<div>来做各种布局&#xff0c;但是<div>本身没有什么实际的含义&#xff0c;就像一个没有名字的盒子。而语义化标签就像是有名…...

考研英语语法全攻略:从基础到长难句剖析​

引言 在考研英语的备考之旅中,语法犹如一座灯塔,为我们在浩瀚的英语知识海洋中指引方向。无论是阅读理解中复杂长难句的解读,还是写作时准确流畅表达的需求,扎实的语法基础都起着至关重要的作用。本文将结合有道考研语法基础入门课的相关内容,为大家全面梳理考研英语语法…...

Vue3 生命周期

回顾Vue2的生命周期 创建&#xff08;创建前&#xff0c;创建完毕&#xff09;beforeCreate、created挂载&#xff08;挂载前&#xff0c;挂载完毕&#xff09;beforeMount、mounted更新&#xff08;更新前&#xff0c;更新完毕&#xff09;beforeUpdate、updated销毁&#xf…...

hbase-05 namespace、数据的确界TTL

要点 掌握HBase的命名空间namespace概念 掌握HBase数据版本确界 掌握HBase数据TTL 1. HBase的namespace 1.1 namespace基本介绍 在HBase中&#xff0c;namespace命名空间指对一组表的逻辑分组&#xff0c;类似RDBMS中的database&#xff0c;方便对表在业务上划分。Apache…...

线程的常见使用方法

Java中的线程并不是真正意义的线程,我们使用的是Thread类来表示线程,而这个类是 JVM 用来管理线程的一个类,也就是说,每个线程都有一个唯一的 Thread对象 与之关联 每一个执行流都需要有一个对象来进行描述,那么一个Thread对象就是用来表述一个线程执行流的,JVM会将这些对象统…...

架构师面试(十一):消息收发

问题 IM 是互联网中非常典型的独立的系统&#xff0c;麻雀虽小但五脏俱全&#xff0c;非常值得深入研究和探讨&#xff0c;继上次IM相关题目之后&#xff0c;我们继续讨论IM相关话题。 关于IM系统【消息收发模型】的相关描述&#xff0c;下面说法错误的有哪几项&#xff1f; …...

MoonSharp 文档一

目录 1.Getting Started 步骤1&#xff1a;在 IDE 中引入 MoonSharp 步骤2&#xff1a;引入命名空间 步骤3&#xff1a;调用脚本 步骤4&#xff1a;运行代码 2.Keeping a Script around 步骤1&#xff1a;复现前教程所有操作 步骤2&#xff1a;改为创建Script对象 步骤…...

【linux网络编程】端口

一、端口&#xff08;Port&#xff09;概述 在计算机网络中&#xff0c;端口&#xff08;Port&#xff09; 是用来标识不同进程或服务的逻辑通信端点。它类似于一座大楼的房间号&#xff0c;帮助操作系统和网络协议区分不同的应用程序&#xff0c;以便正确地传输数据。 1. 端口…...

Vulnhub-Node

目录标题 一、靶机搭建二、信息收集靶机信息扫ip扫开放端口和版本服务信息指纹探测目录扫描 三、Web渗透信息收集zip爆破ssh连接 四、提权内核版本提权 利用信息收集拿到路径得到账户密码&#xff0c;下载备份文件&#xff0c;base64解密后&#xff0c;利用fcrackzip爆破zip压缩…...

RK3568平台(camera篇)camera3_profiles_rk3588.xml解析

camera3_profiles_rk3588.xml 是一个与 Android 相机 HAL(硬件抽象层)相关的配置文件,通常用于定义 Rockchip RK3588 平台上的相机设备及其功能。该文件基于 Android 的 Camera3 HAL 框架,用于描述相机的配置、流配置、分辨率、帧率、格式等信息。 以下是对 camera3_profi…...

高阶哈希算法

SHA-256简介 SHA-256 是 **SHA-2&#xff08;Secure Hash Algorithm 2&#xff09;**家族中的一种哈希算法&#xff0c;由美国国家安全局设计&#xff0c;并于 2001 年发布。它能够将任意长度的数据映射为一个固定长度256 位&#xff0c;即 32 字节的哈希值&#xff0c;通常以…...

Spark数据倾斜深度解析与实战解决方案

Spark数据倾斜深度解析与实战解决方案 一、数据倾斜的本质与影响 数据倾斜是分布式计算中因数据分布不均导致的性能瓶颈现象。当某些Key对应的数据量远超其他Key时,这些"热点Key"所在的Task会消耗80%以上的计算时间,成为整个作业的木桶短板。具体表现为: Task执…...

Kubernetes滚动更新实践

前言 在我之前的项目中&#xff0c;对微服务升级采用的做法是删除整个namespace&#xff0c; 再重新应用所有yaml。 这种方式简单粗暴&#xff0c;但是不可避免的导致服务中断&#xff0c;影响了用户体验 为了解决更新服务导致的服务中断问题&#xff0c; Kubernetes提供了一种…...

Broken pipe

比较常见的一个问题。 但是并不是每个人都能说清楚。 首先注意下写法&#xff1a; Broken pipe # B大写 p小写 主要是grep的时候别写错了 常见的原因 1、客户端关闭连接。 在服务器端处理请求的过程中&#xff0c;客户端突然关闭了连接&#xff0c;例如浏览器关闭、网络断开…...

doris:ClickHouse

Doris JDBC Catalog 支持通过标准 JDBC 接口连接 ClickHouse 数据库。本文档介绍如何配置 ClickHouse 数据库连接。 使用须知​ 要连接到 ClickHouse 数据库&#xff0c;您需要 ClickHouse 23.x 或更高版本 (低于此版本未经充分测试)。 ClickHouse 数据库的 JDBC 驱动程序&a…...

前K个高频单词

692. 前K个高频单词 - 力扣&#xff08;LeetCode&#xff09; 题目描述&#xff1a; 给定一个单词列表 words 和一个整数 k &#xff0c;返回前 k 个出现次数最多的单词。 返回的答案应该按单词出现频率由高到低排序。如果不同的单词有相同出现频率&#xff0c; 按字典顺序 排序…...

恢复IDEA的Load Maven Changes按钮

写代码的时候不知道点到什么东西了&#xff0c;pom文件上的这个弹窗就是不出来了&#xff0c;重启IDEA&#xff0c;reset windos都没用&#xff0c;网上搜也没收到解决方案 然后开打开其他项目窗口时&#xff0c;看到那个的功能名叫 Hide This Notification 于是跑到Setting里…...

【五.LangChain技术与应用】【31.LangChain ReAct Agent:反应式智能代理的实现】

一、ReAct Agent是啥?为什么说它比「普通AI」聪明? 想象一下,你让ChatGPT查快递物流,它可能直接编个假单号糊弄你。但换成ReAct Agent,它会先推理(Reasoning)需要调用哪个接口,再行动(Action)查询真实数据——这就是ReAct的核心:让AI学会「动脑子」再动手。 举个真…...

Leetcode 62: 不同路径

Leetcode 62: 不同路径 问题描述&#xff1a; 一个机器人位于一个 (m \times n) 网格的左上角&#xff08;起始点位于 ((0, 0))&#xff09;。 机器人每次只能向下或向右移动一步。网格的右下角为终点&#xff08;位于 ((m-1, n-1))&#xff09;。 计算机器人从左上角到右下角…...

计算机毕业设计SpringBoot+Vue.js火锅店管理系统(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…...

Docker Desktop 4.38 安装与配置全流程指南(Windows平台)

一、软件定位与特性 Docker Desktop 是容器化应用开发与部署的一体化工具&#xff0c;支持在本地环境创建、管理和运行Docker容器。4.38版本新增GPU加速支持、WSL 2性能优化和Kubernetes 1.28集群管理功能&#xff0c;适用于微服务开发、CI/CD流水线搭建等场景。 二、安装环境…...

算法系列之广度优先搜索解决妖怪和尚过河问题

在算法学习中&#xff0c;广度优先搜索&#xff08;BFS&#xff09;是一种常用的图搜索算法&#xff0c;适用于解决最短路径问题、状态转换问题等。本文将介绍如何利用广度优先搜索解决经典的“妖怪和尚过河问题”。 问题描述 有三个妖怪和三个和尚需要过河。他们只有一条小船…...

【技术白皮书】内功心法 | 第一部分 | IP协议的目的与工作原理(IP地址)

目录 IP协议的介绍IP协议的目的与工作原理IP协议处理过程与信件传递的相似IP协议处理过程与信件传递的区别IP协议中的概念IP数据包IP地址IP地址组成IP地址分类和组成A、B、C三类地址的格式设计特殊类型的IP地址与传统通信地址进行类比IP地址的表示五类IP地址的地址范围IP地址的…...

【Linux】外接硬盘管理

查看外接硬盘信息 连接外接硬盘后&#xff0c;使用以下命令识别设备&#xff1a; lsblk&#xff1a;列出块设备及其挂载点 lsblk示例输出可能显示设备名称如 /dev/sdb。 通过 lsblk -f 可同时显示文件系统类型和 UUID。 fdisk -l&#xff1a;列出所有磁盘的分区信息&#xff…...

【Hadoop】详解Zookeeper选主流程

1. ZooKeeper 的工作原理 Zookeeper 的核心是Zab协议。Zab协议有两种模式&#xff0c;它们分别是恢复模式&#xff08;选主&#xff09;和广播模式&#xff08;同步&#xff09;。 为了保证事务的顺序一致性&#xff0c;Zookeeper采用了递增的事务id号(zxid)来标识事务。所有…...