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

文章目录

  • 1 – Introduction
  • 2 – The Language
    • 2.1 – Lexical Conventions
    • 2.2 – Values and Types
      • 2.2.1 – Coercion

1 – Introduction

Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight scripting language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++).

例子:安装LuaJIT

LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language.

官方页面:https://luajit.org/luajit.html

安装步骤

git clone https://github.com/LuaJIT/LuaJIT.git
make 
make install

安装后的头文件路径:/usr/local/include/luajit-2.1/

ls -lh /usr/local/include/luajit-2.1/
total 44K
-rw-r--r-- 1 root root 5.9K Dec 24 12:27 lauxlib.h
-rw-r--r-- 1 root root 4.5K Dec 24 12:27 luaconf.h
-rw-r--r-- 1 root root  13K Dec 24 12:27 lua.h
-rw-r--r-- 1 root root  135 Dec 24 12:27 lua.hpp
-rw-r--r-- 1 root root 3.0K Dec 24 12:27 luajit.h
-rw-r--r-- 1 root root 1.2K Dec 24 12:27 lualib.h

安装后的库文件路径:/usr/local/lib/libluajit-5.1.so

root@ubuntu:~/luajit# ls -lh /usr/local/lib/libluajit-5.1.so
lrwxrwxrwx 1 root root 31 Dec 24 12:27 /usr/local/lib/libluajit-5.1.so -> libluajit-5.1.so.2.1.1736781742

Being an extension language, Lua has no notion of a “main” program: it only works embedded in a host client, called the embedding program or simply the host.

This host program can invoke functions to execute a piece of Lua code, can write and read Lua variables, and can register C functions to be called by Lua code.

例子:执行 Lua 代码并读取 Lua 变量

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>int main() {lua_State *L = luaL_newstate();  // 创建一个新的 Lua 状态luaL_openlibs(L);  // 打开 Lua 标准库// 执行 Lua 代码定义一个变量const char *lua_code = "x = 42";if (luaL_dostring(L, lua_code) != LUA_OK) {printf("Error: %s\n", lua_tostring(L, -1));return 1;}// 获取 Lua 中的变量 xlua_getglobal(L, "x");  // 将 Lua 全局变量 x 的值压入栈// 检查栈顶的数据类型并获取其值if (lua_isnumber(L, -1)) {double x = lua_tonumber(L, -1);printf("Value of x: %f\n", x);  // 输出 x 的值}lua_pop(L, 1);  // 弹出栈顶的 x 变量lua_close(L);  // 关闭 Lua 状态return 0;
}

编译程序

gcc -o test test.c -I/usr/local/include/luajit-2.1 -lluajit-5.1

输出

Value of x: 42.000000

例子:在 Lua 中修改宿主程序的变量

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>int main() {lua_State *L = luaL_newstate();  // 创建 Lua 状态luaL_openlibs(L);  // 打开 Lua 标准库// 定义一个变量int value = 10;// 将 C 变量传递给 Lualua_pushnumber(L, value);  // 将 value 压栈lua_setglobal(L, "value");  // 将栈顶的值设置为 Lua 中的全局变量 value// 在 Lua 中修改变量if (luaL_dostring(L, "value = value * 2") != LUA_OK) {printf("Error: %s\n", lua_tostring(L, -1));return 1;}// 获取 Lua 中修改后的变量值lua_getglobal(L, "value");if (lua_isnumber(L, -1)) {value = lua_tonumber(L, -1);printf("Modified value: %d\n", value);  // 输出修改后的值}lua_close(L);  // 关闭 Lua 状态return 0;
}

输出

Modified value: 20

例子:从 Lua 中调用 C 函数

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>// 定义一个 C 函数
int add_numbers(lua_State *L) {// 获取 Lua 中传入的参数int a = luaL_checknumber(L, 1);int b = luaL_checknumber(L, 2);// 将返回值压栈lua_pushnumber(L, a + b);return 1;  // 返回 1 个值
}int main() {lua_State *L = luaL_newstate();  // 创建 Lua 状态luaL_openlibs(L);  // 打开 Lua 标准库// 注册 C 函数到 Lualua_register(L, "add_numbers", add_numbers);// 在 Lua 中调用 C 函数if (luaL_dostring(L, "result = add_numbers(10, 20)") != LUA_OK) {printf("Error: %s\n", lua_tostring(L, -1));return 1;}// 获取 Lua 中的返回值lua_getglobal(L, "result");if (lua_isnumber(L, -1)) {double result = lua_tonumber(L, -1);printf("Result from Lua: %f\n", result);  // 输出返回的值}lua_close(L);  // 关闭 Lua 状态return 0;
}

输出

Result from Lua: 30.000000

Through the use of C functions, Lua can be augmented to cope with a wide range of different domains, thus creating customized programming languages sharing a syntactical framework. The Lua distribution includes a sample host program called lua, which uses the Lua library to offer a complete, stand-alone Lua interpreter.

例子:使用 LuaJIT 交互式地执行Lua代码

luajit
LuaJIT 2.1.1736781742 -- Copyright (C) 2005-2025 Mike Pall. https://luajit.org/
JIT: ON SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
> print('hello world')
hello world
> x = 10
> print(x)
10

Lua is free software, and is provided as usual with no guarantees, as stated in its license. The implementation described in this manual is available at Lua’s official web site, www.lua.org.

Like any other reference manual, this document is dry in places. For a discussion of the decisions behind the design of Lua, see the technical papers available at Lua’s web site. For a detailed introduction to programming in Lua, see Roberto’s book, Programming in Lua (Second Edition).

2 – The Language

This section describes the lexis, the syntax, and the semantics of Lua. In other words, this section describes which tokens are valid, how they can be combined, and what their combinations mean.

The language constructs will be explained using the usual extended BNF notation, in which {a} means 0 or more a’s, and [a] means an optional a. Non-terminals are shown like non-terminal, keywords are shown like kword, and other terminal symbols are shown like `**=**´. The complete syntax of Lua can be found in §8 at the end of this manual.

2.1 – Lexical Conventions

Names (also called identifiers) in Lua can be any string of letters, digits, and underscores, not beginning with a digit. This coincides with the definition of names in most languages. (The definition of letter depends on the current locale: any character considered alphabetic by the current locale can be used in an identifier.) Identifiers are used to name variables and table fields.

例子:有效的变量名

i j i10 _ij
aSomewhatLongName _INPUT

The following keywords are reserved and cannot be used as names:

     and       break     do        else      elseifend       false     for       function  ifin        local     nil       not       orrepeat    return    then      true      until     while

Lua is a case-sensitive language: and is a reserved word, but And and AND are two different, valid names.

As a convention, names starting with an underscore followed by uppercase letters (such as _VERSION) are reserved for internal global variables used by Lua.

例子:Lua 内部使用的全局变量

print(_VERSION) -- 版本号print(_G) -- 保存全局变量的表

输出

Lua 5.1
table: 0x7f20e252bd78

The following strings denote other tokens:

     +     -     *     /     %     ^     #==    ~=    <=    >=    <     >     =(     )     {     }     [     ];     :     ,     .     ..    ...

Literal strings can be delimited by matching single or double quotes, and can contain the following C-like escape sequences: ‘\a’ (bell), ‘\b’ (backspace), ‘\f’ (form feed), ‘\n’ (newline), ‘\r’ (carriage return), ‘\t’ (horizontal tab), ‘\v’ (vertical tab), ‘\\’ (backslash), ‘\"’ (quotation mark [double quote]), and ‘\'’ (apostrophe [single quote]).

Moreover, a backslash followed by a real newline results in a newline in the string.

例子:字符串

print('"hello"')
print("'hello'")
print("hello\"")
print('hello\'')
print("hello\n")
print("hello\
")

输出

"hello"
'hello'
hello"
hello'
hellohello

A character in a string can also be specified by its numerical value using the escape sequence \ddd, where ddd is a sequence of up to three decimal digits.(Note that if a numerical escape is to be followed by a digit, it must be expressed using exactly three digits.)

例子:使用转义序列表示字符

print("alo\n123\"")print('\97lo\10\04923"')

输出

alo
123"
alo
123"

这两个字符串是一样的。字符’a’可以使用转义序列’\97’表示,‘a’的ASCII码是十进制数97。同样的,换行符’\n’的ASCII码是十进制数10。字符’1’的ASCII码是十进制数49。

由于字符’1’后面跟着数字字符’23’,所以必须使用3位十进制数’\049’来表示字符’1’,否则’\492’会导致报错无效的转义序列。

invalid escape sequence near ''alo
'

Strings in Lua can contain any 8-bit value, including embedded zeros, which can be specified as ‘\0’.

例子:字符串中包含’\0’

local str = '123\0abc'
print(str)
print(#str) -- 长度为7,包含了字符'\0'的长度

输出

123abc
7

Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs followed by another opening square bracket. So, an opening long bracket of level 0 is written as [[, an opening long bracket of level 1 is written as [=[, and so on. A closing long bracket is defined similarly; for instance, a closing long bracket of level 4 is written as ]====]. A long string starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. Literals in this bracketed form can run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. They can contain anything except a closing bracket of the proper level.

例子:使用长括号的形式定义字符串

page = [[
<html>
<head>
<title>An HTML Page</title>
</head>
<body>
<a href="http://www.lua.org">Lua</a>
</body>
</html>
]]print(page)

输出

<html>
<head>
<title>An HTML Page</title>
</head>
<body>
<a href="http://www.lua.org">Lua</a>
</body>
</html>

For convenience, when the opening long bracket is immediately followed by a newline, the newline is not included in the string. As an example, in a system using ASCII (in which ‘a’ is coded as 97, newline is coded as 10, and ‘1’ is coded as 49), the five literal strings below denote the same string:

     a = 'alo\n123"'a = "alo\n123\""a = '\97lo\10\04923"'a = [[alo123"]]a = [==[alo123"]==]

A numerical constant can be written with an optional decimal part and an optional decimal exponent. Lua also accepts integer hexadecimal constants, by prefixing them with 0x. Examples of valid numerical constants are

     3   3.0   3.1416   314.16e-2   0.31416E1   0xff   0x56

A comment starts with a double hyphen (--) anywhere outside a string. If the text immediately after -- is not an opening long bracket, the comment is a short comment, which runs until the end of the line. Otherwise, it is a long comment, which runs until the corresponding closing long bracket. Long comments are frequently used to disable code temporarily.

例子:短注释和长注释

-- 短注释-- 长注释,注释一个函数
--[[
print(10) -- no action (comment)
--]]---[[ 取消函数注释
print(10) --> 10
--]]

输出

10

小技巧:在长注释前添加-可将长注释变成两个短注释,从而取消注释

2.2 – Values and Types

Lua is a dynamically typed language. This means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type.

All values in Lua are first-class values. This means that all values can be stored in variables, passed as arguments to other functions, and returned as results.

There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.

例子:Lua 的七种数据类型

print(type("Hello world")) --> string
print(type(10.4*3)) --> number
print(type(print)) --> function
print(type(true)) --> boolean
print(type(nil)) --> nil
print(type({})) --> table
print(type(coroutine.create(function () end))) --> thread

输出

string
number
function
boolean
nil
table
thread

userdata 类型的数据只能使用 C API 创建。

Nil is the type of the value nil, whose main property is to be different from any other value; it usually represents the absence of a useful value.

Boolean is the type of the values false and true.

Both nil and false make a condition false; any other value makes it true.

例子:0和空字符串使条件表达式的值为true

if 0 thenprint('true')
endif "" thenprint("true")
end

输出

true
true

Number represents real (double-precision floating-point) numbers. (It is easy to build Lua interpreters that use other internal representations for numbers, such as single-precision float or long integers; see file luaconf.h.)

String represents arrays of characters. Lua is 8-bit clean: strings can contain any 8-bit character, including embedded zeros (‘\0’) (see §2.1).

Lua can call (and manipulate) functions written in Lua and functions written in C (see §2.5.8).

例子:Lua 中调用 C 模块的函数

C模块代码

#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>static int l_dir (lua_State *L) {DIR *dir;struct dirent *entry;int i;const char *path = luaL_checkstring(L, 1);/* open directory */dir = opendir(path);if (dir == NULL) { /* error opening the directory? */lua_pushnil(L); /* return nil */lua_pushstring(L, strerror(errno)); /* and error message */return 2; /* number of results */}/* create result table */lua_newtable(L);i = 1;while ((entry = readdir(dir)) != NULL) {lua_pushnumber(L, i++); /* push key */lua_pushstring(L, entry->d_name); /* push value */lua_settable(L, -3);}closedir(dir);return 1; /* table is already on top */
}static const luaL_Reg mylib[] = {{"dir", l_dir},{NULL, NULL} 
};int luaopen_mylib (lua_State *L) {luaL_register(L, "mylib", mylib);return 1; 
}

编译成动态库

gcc -o mylib.so -shared mylib.c -fPIC -I/usr/local/include/luajit-2.1 -lluajit-5.1

lua中调用C模块的dir函数

require "mylib"a = mylib.dir("/usr")
for i=1, #a doprint(a[i])
end

程序输出/usr目录下的所有目录名

The type userdata is provided to allow arbitrary C data to be stored in Lua variables. This type corresponds to a block of raw memory and has no pre-defined operations in Lua, except assignment and identity test. However, by using metatables, the programmer can define operations for userdata values (see §2.8). Userdata values cannot be created or modified in Lua, only through the C API. This guarantees the integrity of data owned by the host program.

例子:使用C API 创建 userdata 并在 Lua 中使用

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>typedef struct {int value;
} MyData;// 创建一个简单的 `userdata`
static int new_value(lua_State *L) {// 创建一个新的 userdata(MyData 类型)MyData *ud = (MyData *)lua_newuserdata(L, sizeof(MyData));// 初始化数据ud->value = 0;// 创建并设置元表luaL_getmetatable(L, "MyDataMetaTable");lua_setmetatable(L, -2);return 1; // 返回 userdata
}// 获取 userdata 的值
static int get_value(lua_State *L) {MyData *ud = (MyData *)luaL_checkudata(L, 1, "MyDataMetaTable");lua_pushinteger(L, ud->value);return 1;
}// 设置 userdata 的值
static int set_value(lua_State *L) {MyData *ud = (MyData *)luaL_checkudata(L, 1, "MyDataMetaTable");ud->value = luaL_checkinteger(L, 2);return 0;
}// 定义模块方法
static const struct luaL_Reg mydata_methods[] = {{"new", new_value},{"get", get_value},{"set", set_value},{NULL, NULL}
};// 打开模块并注册类型
int luaopen_mydata(lua_State *L) {// 创建并注册元表luaL_newmetatable(L, "MyDataMetaTable");// 注册模块方法luaL_register(L, "mydata", mydata_methods);return 1;
}

编译成动态库

gcc -o mydata.so -shared mydata.c -fPIC -I/usr/local/include/luajit-2.1 -lluajit-5.1

在Lua中使用userdata

local mydata = require("mydata")-- 创建一个MyData类型的userdata
local data = mydata.new()print(data)-- 打印userdata的值
print(mydata.get(data))-- 修改userdata的值
mydata.set(data, 100)
-- 打印新值
print(mydata.get(data))

输出

userdata: 0x7f9868901a80
0
100

The type thread represents independent threads of execution and it is used to implement coroutines (see §2.11). Do not confuse Lua threads with operating-system threads. Lua supports coroutines on all systems, even those that do not support threads.

例子:使用 C API 创建协程

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>int main() {// 初始化 Lua 状态lua_State *L = luaL_newstate();luaL_openlibs(L);// 创建一个新的协程lua_State *co = lua_newthread(L);// 定义 Lua 脚本const char *lua_code = "function my_func() \n""    for i = 1, 5 do \n""        print('Coroutine step: ' .. i) \n""        coroutine.yield() \n""    end \n""end \n";// 加载并执行 Lua 脚本if (luaL_dostring(L, lua_code) != LUA_OK) {fprintf(stderr, "Error loading Lua script: %s\n", lua_tostring(L, -1));lua_close(L);return 1;}// 获取 my_func 函数并传递给协程lua_getglobal(L, "my_func");lua_xmove(L, co, 1);  // 将函数传递给协程// 启动协程,传递 0 个参数int status;while (1) {status = lua_resume(co, 0);  // 每次执行一次协程if (status == LUA_YIELD) {printf("LUA_YIELD\n");} else if (status == LUA_OK) {// 协程执行完毕printf("Coroutine finished\n");break;} else {// 出现错误printf("Error or coroutine finished with error\n");break;}}// 清理lua_close(L);return 0;
}

输出

Coroutine step: 1
LUA_YIELD
Coroutine step: 2
LUA_YIELD
Coroutine step: 3
LUA_YIELD
Coroutine step: 4
LUA_YIELD
Coroutine step: 5
LUA_YIELD
Coroutine finished

例子:Lua 中调用 C 函数,C 函数执行 yield

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>int my_c_function(lua_State *L) {printf("in c function, yield\n");return lua_yield(L, 0);
}int main() {// 初始化 Lua 状态lua_State *L = luaL_newstate();luaL_openlibs(L);// 注册 C 函数lua_register(L, "my_c_function", my_c_function);// 创建一个新的协程lua_State *co = lua_newthread(L);// 定义 Lua 脚本。在 Lua 中调用 C 函数,在 C 函数中 yieldconst char *lua_code = "function my_func() \n""    for i = 1, 5 do \n""        print('Coroutine step: ' .. i) \n""        my_c_function() \n""        print('Coroutine continue') \n""    end \n""end \n";// 加载并执行 Lua 脚本if (luaL_dostring(L, lua_code) != LUA_OK) {fprintf(stderr, "Error loading Lua script: %s\n", lua_tostring(L, -1));lua_close(L);return 1;}// 获取 my_func 函数并传递给协程lua_getglobal(L, "my_func");lua_xmove(L, co, 1);  // 将函数传递给协程// 启动协程,传递 0 个参数int status;while (1) {status = lua_resume(co, 0);  // 每次执行一次协程if (status == LUA_YIELD) {} else if (status == LUA_OK) {// 协程执行完毕printf("Coroutine finished\n");break;} else {// 出现错误printf("Error or coroutine finished with error\n");break;}}// 清理lua_close(L);return 0;
}

输出

Coroutine step: 1
in c function, yield
Coroutine continue
Coroutine step: 2
in c function, yield
Coroutine continue
Coroutine step: 3
in c function, yield
Coroutine continue
Coroutine step: 4
in c function, yield
Coroutine continue
Coroutine step: 5
in c function, yield
Coroutine continue
Coroutine finished

注意:C 函数 yield 后,后续就不能继续进入 C 函数执行!

The type table implements associative arrays, that is, arrays that can be indexed not only with numbers, but with any value (except nil). Tables can be heterogeneous; that is, they can contain values of all types (except nil).

Tables are the sole data structuring mechanism in Lua; they can be used to represent ordinary arrays, symbol tables, sets, records, graphs, trees, etc.

补充:Lua uses tables to represent modules, packages, and objects as well. When we write io.read, we mean “the read function from the io module”. For Lua, this means “index the table io using the string “read” as the key”.

To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"]. There are several convenient ways to create tables in Lua (see §2.5.7).

Like indices, the value of a table field can be of any type (except nil). In particular, because functions are first-class values, table fields can contain functions. Thus tables can also carry methods (see §2.5.9).

Tables, functions, threads, and (full) userdata values are objects: variables do not actually contain these values, only references to them. Assignment, parameter passing, and function returns always manipulate references to such values; these operations do not imply any kind of copy.

The library function type returns a string describing the type of a given value.

2.2.1 – Coercion

Lua provides automatic conversion between string and number values at run time. Any arithmetic operation applied to a string tries to convert this string to a number, following the usual conversion rules. Conversely, whenever a number is used where a string is expected, the number is converted to a string, in a reasonable format.

例子:字符串和数字的自动转换

print("10" + 1) --> 11
print("10 + 1") --> 10 + 1
print("-5.3e-10"*"2") --> -1.06e-09
print(10 .. 20) --> 1020
print("hello" + 1) -- ERROR (cannot convert "hello")

输出

11
10 + 1
-1.06e-09
1020
luajit: 3.lua:5: attempt to perform arithmetic on a string value
stack traceback:3.lua:5: in main chunk[C]: at 0x00404b20

For complete control over how numbers are converted to strings, use the format function from the string library (see string.format).

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/70281.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

unity学习47:寻路和导航,unity2022后版本如何使用 Navmesh 和 bake

目录 1 寻路和导航对移动的不同 1.1 基础的移动功能 1.1.1 基础移动 1.1.2 智能导航寻路 1.1.3 智能导航寻路还可以 2 如何实现这个效果&#xff1f; 2.1 通过地图网格的形式 2.1.1 警告信息 the static value has been deprecated的对应搜索 2.1.2 新的navigation ba…

达梦存储过程执行后 sql日志信息粗读

如何调试达梦存储过程&#xff1f;快速定位问题 dmgdb 或 manager图形工具 我觉得还可以靠sql日志和DBMS_OUTPUT包&#xff0c;不过最省事的办法放到了最后面&#xff0c;一个sql就能搞清楚了 来段演示代码 set serveroutput on drop table t1; create TABLE t1 (id int, gc…

fpga助教面试题

第一题 module sfp_pwm( input wire clk, //clk is 200M input wire rst_n, input wire clk_10M_i, input wire PPS_i, output reg pwm ) reg [6:0] cunt ;always (posedge clk ) beginif(!rst_n)cunt<0;else if(cunt19) //200M是10M的20倍cunt<0;elsecunt<cunt1;…

【分布式】Hadoop完全分布式的搭建(零基础)

Hadoop完全分布式的搭建 环境准备&#xff1a; &#xff08;1&#xff09;VMware Workstation Pro17&#xff08;其他也可&#xff09; &#xff08;2&#xff09;Centos7 &#xff08;3&#xff09;FinalShell &#xff08;一&#xff09;模型机配置 0****&#xff09;安…

GPT-Sovits:语音克隆训练-遇坑解决

前言 本来以为3050完全无法执行GPT-Sovits训练的&#xff0c;但经过实践发现其实是可以&#xff0c;并且仅花费了十数分钟便成功训练和推理验证了自己的语音模型。 官方笔记&#xff1a;GPT-SoVITS指南 语雀 项目地址&#xff1a;https://github.com/RVC-Boss/GPT-SoVITS 本人…

React之旅-03 路由

做为前端开发框架&#xff0c;React 的组件化设计思想&#xff0c;使前端开发变得更加灵活高效。对于大型复杂的项目来说&#xff0c;页面之间的导航变得尤为重要。因此如何管理路由&#xff0c;是所有开发者必须考虑的问题。 React 官方推荐的路由库-React Router&#xff0c…

Word接入DeepSeek(API的作用)

1.打开”Word”&#xff0c;点击“文件”。 2.点击“选项”。 3.点击“信任中心”——“信任中心设置”。 4. 勾选”启用所有宏“&#xff0c;点击”确定“。 5.点击“自定义功能区”&#xff0c;勾选上“开发工具”&#xff0c;点击“确定”。 6.返回“文件——开发工具“下的…

SQL知识体系

SQL复习 MySQL SQL介绍 SQL SQL的全拼是什么&#xff1f; SQL全拼&#xff1a;Structured Query Language&#xff0c;也叫结构化查询语言。 SQL92和SQL99有什么区别呢&#xff1f; SQL92和SQL99分别代表了92年和99年颁布的SQL标准。 在 SQL92 中采用&#xff08;&#xff…

网络安全治理模型

0x02 知识点 安全的目标是提供 可用性 Avialability机密性 confidentiality完整性 Integrity真实性 Authenticity不可否认性 Nonrepudiation 安全治理是一个提供监督、问责和合规性的框架 信息安全系统 Information Security Management System ISMS 策略&#xff0c;工作程…

Ubuntu学习备忘

1. 打开Terminal快捷键 ctrl alt t 2.Ubuntu22.04的root没有默认初始密码&#xff0c; 为root设置密码&#xff0c;下面链接的step1, How to allow GUI root login on Ubuntu 22.04 Jammy Jellyfish Linux - LinuxConfig

C#: 创建Excel文件并在Excel中写入数据库中的数据

实现思路&#xff1a; 1.检查数据是否可导出 2.弹出文件保存对话框 3.删除已存在的同名文件 4.创建 Excel 应用实例 5.导出表头 6.导出数据 7.保存 Excel 文件 8.释放 Excel 资源 9.导出成功提示 static void ExportToExcel(DataTable Data, string fileName) { // 如果表格…

DeepSeek 和 ChatGPT 在特定任务中的表现:逻辑推理与创意生成

&#x1f381;个人主页&#xff1a;我们的五年 &#x1f50d;系列专栏&#xff1a;Linux网络编程 &#x1f337;追光的人&#xff0c;终会万丈光芒 &#x1f389;欢迎大家点赞&#x1f44d;评论&#x1f4dd;收藏⭐文章 ​ Linux网络编程笔记&#xff1a; https://blog.cs…

HTTP2.0 和 HTTP1.1 的区别

多路复用&#xff08;优化管道&#xff09;&#xff0c;基于HTTPS&#xff0c;二进制帧&#xff0c;Header压缩&#xff0c;服务器推送 多路复用&#xff1a;HTTP/2.0 在一个连接里&#xff0c;客户端和浏览器都可以同时发送多个请求和响应&#xff0c;而不用按照顺序一一对应&…

【物联网】电子电路基础知识

文章目录 一、基本元器件1. 电阻2. 电容3. 电感4. 二极管(1)符号(2)特性(3)实例分析5. 三极管(1)符号(2)开关特性(3)实例6. MOS管(产效应管)(1)符号(2)MOS管极性判定(3)MOS管作为开关(4)MOS管vs三极管7. 门电路(1)与门(2)或门(3)非门二、常用元器件…

基于ffmpeg+openGL ES实现的视频编辑工具-解码(四)

在开发视频编辑工具时,预览功能是基石,它涵盖视频、图片以及音频播放,而视频解码则是实现视频预览及后续编辑操作的关键环节。本文聚焦于基于 FFmpeg 实现视频解码的过程,详细阐述开发中遭遇的痛点、对应的解决方式,以及核心代码的运作原理。 一、开发背景与目标 视频编…

python shlex

python shlex 核心函数 shlex.split(s, commentsFalse, posixTrue) 作用&#xff1a;将字符串按类似 Shell 的语法规则分割成参数列表&#xff0c;常用于安全处理命令行输入。参数说明&#xff1a; s&#xff08;必需&#xff09;: 待分割的字符串&#xff08;如 “ls -l ‘…

软件测试用例设计方法之正交表

一、概念 能够使用最小的测试过程集合获得最大的测试覆盖率&#xff0c;从全面试验中挑选出有代表性的点进行测试。适用于配置类软件&#xff0c;组合比较多的情况。 正交表Ln(m^k)&#xff1a; 特点&#xff1a;均匀分散、整齐可比、高效、快速、经济 n&#xff1a;正交表的…

Cursor实战:Web版背单词应用开发演示

Cursor实战&#xff1a;Web版背单词应用开发演示 需求分析自行编写需求文档借助Cursor生成需求文档 前端UI设计后端开发项目结构环境参数数据库设计安装Python依赖运行应用 前端代码修改测试前端界面 测试数据生成功能测试Bug修复 总结 在上一篇《Cursor AI编程助手不完全指南》…

DeepSeek与ChatGPT:会取代搜索引擎和人工客服的人工智能革命

云边有个稻草人-CSDN博客 在众多创新技术中&#xff0c;DeepSeek和ChatGPT无疑是最为引人注目的。它们通过强大的搜索和对话生成能力&#xff0c;能够改变我们与计算机交互的方式&#xff0c;帮助我们高效地获取信息&#xff0c;增强智能服务。本文将深入探讨这两项技术如何结合…

JavaScript中判断元素是否在可视区域内

JavaScript中判断元素是否在可视区域内 1.有什么应用2.方法1-----使用offsetTop、scrollTop3.方法2-----getBoundingClientRect4.方法3-----Intersection Observer 1.有什么应用 懒加载列表的无限滚动计算广告元素的曝光情况 2.方法1-----使用offsetTop、scrollTop offsetTo…