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

Rust vs Go:常用语法对比(十二)

alt

题图来自 Rust vs Go in 2023[1]


221. Remove all non-digits characters

Create string t from string s, keeping only digit characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

删除所有非数字字符

package main

import (
 "fmt"
 "regexp"
)

func main() {
 s := `height="168px"`

 re := regexp.MustCompile("[^\\d]")
 t := re.ReplaceAllLiteralString(s, "")

 fmt.Println(t)
}

168


fn main() {
    let t: String = "Today is the 14th of July"
        .chars()
        .filter(|c| c.is_digit(10))
        .collect();

    dbg!(t);
}

[src/main.rs:7] t = "14"


222. Find first index of an element in list

Set i to the first index in list items at which the element x can be found, or -1 if items does not contain x.

在列表中查找元素的第一个索引

package main

import (
 "fmt"
)

func main() {
 items := []string{"huey""dewey""louie"}
 x := "dewey"

 i := -1
 for j, e := range items {
  if e == x {
   i = j
   break
  }
 }

 fmt.Printf("Found %q at position %d in %q", x, i, items)
}

Found "dewey" at position 1 in ["huey" "dewey" "louie"]


fn main() {
    let items = ['A', '🎂', '㍗'];
    let x = '💩';

    match items.iter().position(|y| *y == x) {
        Some(i) => println!("Found {} at position {}.", x, i),
        None => println!("There is no {} in the list.", x),
    }
}

There is no 💩 in the list.

or

fn main() {
    let items = [42, -312];

    {
        let x = 12;

        let i = items.iter().position(|y| *y == x).map_or(-1, |n| n as i32);

        println!("{} => {}", x, i)
    }

    {
        let x = 13;

        let i = items.iter().position(|y| *y == x).map_or(-1, |n| n as i32);

        println!("{} => {}", x, i)
    }
}

12 => 2
13 => -1

223. for else loop

Loop through list items checking a condition. Do something else if no matches are found.
A typical use case is looping through a series of containers looking for one that matches a condition. If found, an item is inserted; otherwise, a new container is created.
These are mostly used as an inner nested loop, and in a location where refactoring inner logic into a separate function reduces clarity.

for else循环

package main

import (
 "fmt"
)

func main() {
 items := []string{"foo""bar""baz""qux"}

 for _, item := range items {
  if item == "baz" {
   fmt.Println("found it")
   goto forelse
  }
 }
 {
  fmt.Println("never found it")
 }
        forelse:
}

found it


fn main() {
    let items: &[&str] = &["foo""bar""baz""qux"];

    let mut found = false;
    for item in items {
        if item == &"baz" {
            println!("found it");
            found = true;
            break;
        }
    }
    if !found {
        println!("never found it");
    }
}

found it

or

fn main() {
     let items: &[&str] = &["foo""bar""baz""qux"];

    if let None = items.iter().find(|&&item| item == "rockstar programmer") {
        println!("NotFound");
    };
}

NotFound

or

fn main() {
    let items: &[&str] = &["foo""bar""baz""qux"];

    items
        .iter()
        .find(|&&item| item == "rockstar programmer")
        .or_else(|| {
            println!("NotFound");
            Some(&"rockstar programmer")
        });
}

NotFound


224. Add element to the beginning of the list

Insert element x at the beginning of list items.

将元素添加到列表的开头

package main

import (
 "fmt"
)

type T int

func main() {
 items := []T{421337}
 var x T = 7
 
 items = append([]T{x}, items...)

 fmt.Println(items)
}

[7 42 1337]

or

package main

import (
 "fmt"
)

type T int

func main() {
 items := []T{421337}
 var x T = 7

 items = append(items, x)
 copy(items[1:], items)
 items[0] = x

 fmt.Println(items)
}

[7 42 1337]


use std::collections::VecDeque;

fn main() {
    let mut items = VecDeque::new();
    items.push_back(22);
    items.push_back(33);
    let x = 11;

    items.push_front(x);

    println!("{:?}", items);
}

[11, 22, 33]


225. Declare and use an optional argument

Declare an optional integer argument x to procedure f, printing out "Present" and its value if it is present, "Not present" otherwise

声明并使用可选参数

package main

func f(x ...int) {
 if len(x) > 0 {
  println("Present", x[0])
 } else {
  println("Not present")
 }
}

func main() {
 f()
 f(1)
}

Go does not have optional arguments, but to some extend, they can be mimicked with a variadic parameter. x is a variadic parameter, which must be the last parameter for the function f. Strictly speaking, x is a list of integers, which might have more than one element. These additional elements are ignored.

Not present
Present 1

fn f(x: Option<()>) {
    match x {
        Some(x) => println!("Present {}", x),
        None => println!("Not present"),
    }
}

226. Delete last element from list

Remove the last element from list items.

从列表中删除最后一个元素

package main

import (
 "fmt"
)

func main() {
 items := []string{"banana""apple""kiwi"}
 fmt.Println(items)

 items = items[:len(items)-1]
 fmt.Println(items)
}
[banana apple kiwi]
[banana apple]

fn main() {
    let mut items = vec![112233];

    items.pop();

    println!("{:?}", items);
}

[11, 22]


227. Copy list

Create new list y containing the same elements as list x.
Subsequent modifications of y must not affect x (except for the contents referenced by the elements themselves if they contain pointers).

复制列表

package main

import (
 "fmt"
)

func main() {
 type T string
 x := []T{"Never""gonna""shower"}

 y := make([]T, len(x))
 copy(y, x)

 y[2] = "give"
 y = append(y, "you""up")

 fmt.Println(x)
 fmt.Println(y)
}

[Never gonna shower]
[Never gonna give you up]

fn main() {
    let mut x = vec![432];

    let y = x.clone();

    x[0] = 99;
    println!("x is {:?}", x);
    println!("y is {:?}", y);
}
x is [9932]
y is [432]

228. Copy a file

Copy the file at path src to dst.

复制文件

package main

import (
 "fmt"
 "io/ioutil"
 "log"
 "os"
)

func main() {
 src, dst := "/tmp/file1""/tmp/file2"

 err := copy(dst, src)
 if err != nil {
  log.Fatalln(err)
 }

 stat, err := os.Stat(dst)
 if err != nil {
  log.Fatalln(err)
 }
 fmt.Println(dst, "exists, it has size", stat.Size(), "and mode", stat.Mode())
}

func copy(dst, src string) error {
 data, err := ioutil.ReadFile(src)
 if err != nil {
  return err
 }
 stat, err := os.Stat(src)
 if err != nil {
  return err
 }
 return ioutil.WriteFile(dst, data, stat.Mode())
}

func init() {
 data := []byte("Hello")
 err := ioutil.WriteFile("/tmp/file1", data, 0644)
 if err != nil {
  log.Fatalln(err)
 }
}

/tmp/file2 exists, it has size 5 and mode -rw-r--r--

or

package main

import (
 "fmt"
 "io/ioutil"
 "log"
 "os"
)

func main() {
 src, dst := "/tmp/file1""/tmp/file2"

 err := copy(dst, src)
 if err != nil {
  log.Fatalln(err)
 }

 stat, err := os.Stat(dst)
 if err != nil {
  log.Fatalln(err)
 }
 fmt.Println(dst, "exists, it has size", stat.Size(), "and mode", stat.Mode())
}

func copy(dst, src string) error {
 data, err := ioutil.ReadFile(src)
 if err != nil {
  return err
 }
 stat, err := os.Stat(src)
 if err != nil {
  return err
 }
 err = ioutil.WriteFile(dst, data, stat.Mode())
 if err != nil {
  return err
 }
 return os.Chmod(dst, stat.Mode())
}

func init() {
 data := []byte("Hello")
 err := ioutil.WriteFile("/tmp/file1", data, 0777)
 if err != nil {
  log.Fatalln(err)
 }
 err = os.Chmod("/tmp/file1"0777)
 if err != nil {
  log.Fatalln(err)
 }
}

/tmp/file2 exists, it has size 5 and mode -rwxrwxrwx

or

package main

import (
 "fmt"
 "io"
 "io/ioutil"
 "log"
 "os"
)

func main() {
 src, dst := "/tmp/file1""/tmp/file2"

 err := copy(dst, src)
 if err != nil {
  log.Fatalln(err)
 }

 stat, err := os.Stat(dst)
 if err != nil {
  log.Fatalln(err)
 }
 fmt.Println(dst, "exists, it has size", stat.Size(), "and mode", stat.Mode())
}

func copy(dst, src string) error {
 f, err := os.Open(src)
 if err != nil {
  return err
 }
 defer f.Close()
 stat, err := f.Stat()
 if err != nil {
  return err
 }
 g, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, stat.Mode())
 if err != nil {
  return err
 }
 defer g.Close()
 _, err = io.Copy(g, f)
 if err != nil {
  return err
 }
 return os.Chmod(dst, stat.Mode())
}

func init() {
 data := []byte("Hello")
 err := ioutil.WriteFile("/tmp/file1", data, 0777)
 if err != nil {
  log.Fatalln(err)
 }
 err = os.Chmod("/tmp/file1"0777)
 if err != nil {
  log.Fatalln(err)
 }
}

/tmp/file2 exists, it has size 5 and mode -rwxrwxrwx


use std::fs;

fn main() {
    let src = "/etc/fstabZ";
    let dst = "fstab.bck";

    let r = fs::copy(src, dst);

    match r {
        Ok(v) => println!("Copied {:?} bytes", v),
        Err(e) => println!("error copying {:?} to {:?}: {:?}", src, dst, e),
    }
}

error copying "/etc/fstabZ" to "fstab.bck": Os { code: 2, kind: NotFound, message: "No such file or directory" }


231. Test if bytes are a valid UTF-8 string

Set b to true if the byte sequence s consists entirely of valid UTF-8 character code points, false otherwise.

测试字节是否是有效的UTF-8字符串

package main

import (
 "fmt"
 "unicode/utf8"
)

func main() {
 {
  s := []byte("Hello, 世界")
  b := utf8.Valid(s)
  fmt.Println(b)
 }
 {
  s := []byte{0xff0xfe0xfd}
  b := utf8.Valid(s)
  fmt.Println(b)
 }
}

true
false

fn main() {
    {
        let bytes = [0xc30x810x720x760xc30xad0x7a];

        let b = std::str::from_utf8(&bytes).is_ok();
        println!("{}", b);
    }

    {
        let bytes = [0xc30x810x810x760xc30xad0x7a];

        let b = std::str::from_utf8(&bytes).is_ok();
        println!("{}", b);
    }
}

true
false

234. Encode bytes to base64

Assign to string s the standard base64 encoding of the byte array data, as specified by RFC 4648.

将字节编码为base64

package main

import (
 "encoding/base64"
 "fmt"
)

func main() {
 data := []byte("Hello world")
 s := base64.StdEncoding.EncodeToString(data)
 fmt.Println(s)
}

SGVsbG8gd29ybGQ=


//use base64;

fn main() {
    let d = "Hello, World!";

    let b64txt = base64::encode(d);
    println!("{}", b64txt);
}

SGVsbG8sIFdvcmxkIQ==


235. Decode base64

Assign to byte array data the bytes represented by the base64 string s, as specified by RFC 4648.

解码base64

package main

import (
 "encoding/base64"
 "fmt"
)

func main() {
 str := "SGVsbG8gd29ybGQ="

 data, err := base64.StdEncoding.DecodeString(str)
 if err != nil {
  fmt.Println("error:", err)
  return
 }

 fmt.Printf("%q\n", data)
}

"Hello world"


//use base64;

fn main() {
    let d = "SGVsbG8sIFdvcmxkIQ==";

    let bytes = base64::decode(d).unwrap();
    println!("Hex: {:x?}", bytes);
    println!("Txt: {}", std::str::from_utf8(&bytes).unwrap());
}

Hex: [48656c, 6c, 6f, 2c, 20576f, 726c, 6421]
Txt: Hello, World!

237. Xor integers

Assign to c the result of (a xor b)

异或运算

异或整数

package main

import (
 "fmt"
)

func main() {
 a, b := 23042
 c := a ^ b

 fmt.Printf("a is %12b\n", a)
 fmt.Printf("b is %12b\n", b)
 fmt.Printf("c is %12b\n", c)
 fmt.Println("c ==", c)
}

a is     11100110
b is       101010
c is     11001100
c == 204

or

package main

import (
 "fmt"
 "math/big"
)

func main() {
 a, b := big.NewInt(230), big.NewInt(42)
 c := new(big.Int)
 c.Xor(a, b)

 fmt.Printf("a is %12b\n", a)
 fmt.Printf("b is %12b\n", b)
 fmt.Printf("c is %12b\n", c)
 fmt.Println("c ==", c)
}
a is     11100110
b is       101010
c is     11001100
c == 204

fn main() {
    let a = 230;
    let b = 42;
    let c = a ^ b;

    println!("{}", c);
}

204


238. Xor byte arrays

Write in a new byte array c the xor result of byte arrays a and b.
a and b have the same size.

异或字节数组

package main

import (
 "fmt"
)

func main() {
 a, b := []byte("Hello"), []byte("world")

 c := make([]bytelen(a))
 for i := range a {
  c[i] = a[i] ^ b[i]
 }

 fmt.Printf("a is %08b\n", a)
 fmt.Printf("b is %08b\n", b)
 fmt.Printf("c is %08b\n", c)
 fmt.Println("c ==", c)
 fmt.Printf("c as string would be %q\n"string(c))
}

a is [01001000 01100101 01101100 01101100 01101111]
b is [01110111 01101111 01110010 01101100 01100100]
c is [00111111 00001010 00011110 00000000 00001011]
c == [63 10 30 0 11]
c as string would be "?\n\x1e\x00\v"

or

package main

import (
 "fmt"
)

type T [5]byte

func main() {
 var a, b T
 copy(a[:], "Hello")
 copy(b[:], "world")

 var c T
 for i := range a {
  c[i] = a[i] ^ b[i]
 }

 fmt.Printf("a is %08b\n", a)
 fmt.Printf("b is %08b\n", b)
 fmt.Printf("c is %08b\n", c)
 fmt.Println("c ==", c)
 fmt.Printf("c as string would be %q\n"string(c[:]))
}
a is [01001000 01100101 01101100 01101100 01101111]
b is [01110111 01101111 01110010 01101100 01100100]
c is [00111111 00001010 00011110 00000000 00001011]
c == [63 10 30 0 11]
c as string would be "?\n\x1e\x00\v"

fn main() {
    let a: &[u8] = "Hello".as_bytes();
    let b: &[u8] = "world".as_bytes();

    let c: Vec<_> = a.iter().zip(b).map(|(x, y)| x ^ y).collect();

    println!("{:?}", c);
}

[63, 10, 30, 0, 11]


239. Find first regular expression match

Assign to string x the first word of string s consisting of exactly 3 digits, or the empty string if no such match exists.
A word containing more digits, or 3 digits as a substring fragment, must not match.

查找第一个正则表达式匹配项

package main

import (
 "fmt"
 "regexp"
)

func main() {
 re := regexp.MustCompile(`\b\d\d\d\b`)
 for _, s := range []string{
  "",
  "12",
  "123",
  "1234",
  "I have 12 goats, 3988 otters, 224 shrimps and 456 giraffes",
  "See p.456, for word boundaries",
 } {
  x := re.FindString(s)
  fmt.Printf("%q -> %q\n", s, x)
 }
}
"" -> ""
"12" -> ""
"123" -> "123"
"1234" -> ""
"I have 12 goats, 3988 otters, 224 shrimps and 456 giraffes" -> "224"
"See p.456, for word boundaries" -> "456"

use regex::Regex;

fn main() {
    let sentences = vec![
        "",
        "12",
        "123",
        "1234",
        "I have 12 goats, 3988 otters, 224 shrimps and 456 giraffes",
        "See p.456, for word boundaries",
    ];
    for s in sentences {
        let re = Regex::new(r"\b\d\d\d\b").expect("failed to compile regex");
        let x = re.find(s).map(|x| x.as_str()).unwrap_or("");
        println!("[{}] -> [{}]", &s, &x);
    }
}

[] -> []
[12] -> []
[123] -> [123]
[1234] -> []
[I have 12 goats, 3988 otters, 224 shrimps and 456 giraffes] -> [224]
[See p.456for word boundaries] -> [456]

240. Sort 2 lists together

Lists a and b have the same length. Apply the same permutation to a and b to have them sorted based on the values of a.

将两个列表排序在一起.列表a和b的长度相同。对a和b应用相同的排列,根据a的值对它们进行排序。

package main

import (
 "fmt"
 "sort"
)

type K int
type T string

type sorter struct {
 k []K
 t []T
}

func (s *sorter) Len() int {
 return len(s.k)
}

func (s *sorter) Swap(i, j int) {
 // Swap affects 2 slices at once.
 s.k[i], s.k[j] = s.k[j], s.k[i]
 s.t[i], s.t[j] = s.t[j], s.t[i]
}

func (s *sorter) Less(i, j int) bool {
 return s.k[i] < s.k[j]
}

func main() {
 a := []K{9348}
 b := []T{"nine""three""four""eight"}

 sort.Sort(&sorter{
  k: a,
  t: b,
 })

 fmt.Println(a)
 fmt.Println(b)
}

[3 4 8 9]
[three four eight nine]

fn main() {
    let a = vec![30204010];
    let b = vec![101102103104];

    let mut tmp: Vec<_> = a.iter().zip(b).collect();
    tmp.as_mut_slice().sort_by_key(|(&x, _y)| x);
    let (aa, bb): (Vec<i32>, Vec<i32>) = tmp.into_iter().unzip();

    println!("{:?}, {:?}", aa, bb);
}

[10, 20, 30, 40], [104, 102, 101, 103]


参考资料

[1]

Rust vs Go in 2023: https://bitfieldconsulting.com/golang/rust-vs-go

本文由 mdnice 多平台发布

相关文章:

Rust vs Go:常用语法对比(十二)

题图来自 Rust vs Go in 2023[1] 221. Remove all non-digits characters Create string t from string s, keeping only digit characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. 删除所有非数字字符 package mainimport ( "fmt" "regexp")func main() { s : hei…...

jmeter接口测试、压力测试简单实现

jmeter测试的组件执行顺序&#xff1a; 测试计划—>线程组—>配置元件—>前置处理器—>定时器—>逻辑控制器—>取样器—>后置处理器—>断言—>监听器 组件的作用范围&#xff1a; 同级组件同级组件下的子组件父组件 目前市面上的三类接口 1、基…...

PysparkNote006---pycharm加载spark环境

pycharm配置pyspark环境&#xff0c;本地执行pyspark代码 spark安装、添加环境变量不提了 File-Settings-Project-Project Structure-add content root添加如下两个路径 D:\code\spark\python\lib\py4j-0.10.7-src.zipD:\code\spark\python\lib\pyspark.zip 2023-07-26 阴 于…...

19套项目实战系列--Spring Cloud Spring Boot(整套源码)

整套大型项目源码&#xff0c;需要的回复私信&#xff1a;19 ┃ ┣━01.19套项目实战系列 ┃ ┃ ┣━第04套【项目实战】Spring Cloud分布式微服务实战&#xff0c;打造大型自媒体3大业务平台 分布式前后端分离项目分层聚合 养成应对复杂业务的综合技术能力 ┃ ┃ ┃ ┣━1-…...

TCP/IP协议详解(二)

目录内容 TCP协议的可靠性 TCP的三次握手 TCP的四次挥手 C#中&#xff0c;TCP/IP建立 三次握手和四次挥手常见面试题 在上一篇文章中讲解了TCP/IP的由来以及报文格式&#xff0c;详情请见上一篇文章&#xff0c;现在接着来讲讲TCP/IP的可靠性以及通过代码的实现。 在TCP首部的…...

Linux6.2 ansible 自动化运维工具(机器管理工具)

文章目录 计算机系统5G云计算第一章 LINUX ansible 自动化运维工具&#xff08;机器管理工具&#xff09;一、概述二、ansible 环境安装部署三、ansible 命令行模块1.command 模块2.shell 模块3.cron 模块4.user 模块5.group 模块6.copy 模块7.file 模块8.hostname 模块9.ping …...

前端面试题 —— React (二)

目录 一、React 组件中怎么做事件代理&#xff1f;它的原理是什么&#xff1f; 二、React.Component 和 React.PureComponent 的区别 三、Component, Element, Instance 之间有什么区别和联系&#xff1f; 四、React声明组件有哪几种方法&#xff0c;有什么不同&#xff1f…...

【分享帖】LCD的MCU接口和SPI接口详解

LCD&#xff08;Liquid Crystal Display&#xff09;液晶屏&#xff0c;作为电子产品的重要组成部分&#xff0c;是终端用户与电子产品交互的重要载体。现在市场上的LCD&#xff0c;按照尺寸、功能、接口、用途等分为很多种&#xff0c;本文主要介绍如下两种LCD物理接口&#x…...

【Java】使用@Expose注解和excludeFieldsWithoutExposeAnnotatGson()方法将toJson()过程的部分字段忽略

要在使用 Gson 的 toJson() 方法时忽略 List 中的某些字段&#xff0c;你可以使用 Gson 的 Expose 注解和 excludeFieldsWithoutExposeAnnotation() 方法。 首先&#xff0c;在 List 中的 Bean 类中&#xff0c;使用 Expose 注解标记你想要序列化的字段&#xff1a; public c…...

移动硬盘不显示怎么办?正确解决方式看这里!

移动硬盘为存储带来了很大的方便&#xff0c;在对数据存储时&#xff0c;可做到即插即用&#xff0c;且其体积小、容量大&#xff0c;且比较安全可靠。但在实际的使用中&#xff0c;也会出现各种问题。请看下面2个常见案例。 案例1&#xff1a;“各位朋友&#xff0c;我新买了一…...

MySQL 5.7.39 关于时间精度

前情提要 当EndTime的数据类型为datetime when the end_time’s dataType is datetime; entity.EndTime DateTime.MaxValue; context.Set<T>().Add(entity);当保存 ‘9999-12-31 23:59:59’ 这个值时,发生报错。 A crash has happended in the program when saving ‘…...

宝塔设置云服务器mysql端口转发,实现本地电脑访问云mysql

环境&#xff1a;centos系统使用宝塔面板 实现功能&#xff1a;宝塔设置云服务器mysql端口转发&#xff0c;实现本地电脑访问mysql 1.安装mysql、PHP-7.4.33、phpMyAdmin 5.0 软件商店》搜索 mysql安装即可 软件商店》搜索 PHP安装7.4.33即可&#xff08;只需要勾选快速安装&…...

centos下安装ftp-读取目录列表失败-

1.下载安装ftp服务器端和客户端 #1.安装yum -y install vsftpdyum -y install ftp #2.修改配置文件vim /etc/vsftpd.conflocal_enablesYESwrite_enableYESanonymous_enableYESanon_mkdir_write_enableYES //允许匿名用户在FTP上创建目录anon_upload_enableYES //允许匿名用户…...

0101sub-process /usr/bin/dpkg returned an error code-dpkg-linux问题集

kali linux有段时间没用了&#xff0c;现在有点时间想着继续学习下网络安全&#xff0c;那就升级更新下。 apt-get update && apt-get upgrade等待一段时间后&#xff0c;下载完毕执行安装和更新&#xff0c;更新的过程中报错退出了 问题1 更新kali-themes 需要kali-t…...

流控平台Sentinel搭建和接入教程

流量控制和限流是大型系统必不可少的组成部分&#xff0c;Sentinel是Alibaba提供的一款特别好用的专业工具&#xff0c;属于那种看起来很牛&#xff0c;用起来也很牛的工具&#xff0c;下面记录一下接入的过程。 一&#xff0c;搭建平台 1&#xff0c;下载jar包 地址&#x…...

使用 docker 一键部署 MongoDB

目录 1. 前期准备 2. 导入镜像 3. 部署MongoDB脚本 4. 配置模板文件 5. 部署MongoDB 6. 部署后配置 7. 基本维护 1. 前期准备 新部署前可以从仓库&#xff08;repository&#xff09;下载 MongoDB 镜像&#xff0c;或者从已有部署中的镜像生成文件&#xff1a; # 查看…...

【深度学习】Inst-Inpaint: Instructing to Remove Objects with Diffusion Models,指令式图像修复

论文&#xff1a;https://arxiv.org/abs/2304.03246 code:http://instinpaint.abyildirim.com/ 文章目录 AbstractIntroductionRelated WorkDataset GenerationMethodPS Abstract 图像修复任务是指从图像中擦除不需要的像素&#xff0c;并以语义一致且逼真的方式填充它们。传统…...

创建维基WIKI百科和建立百度百科有何不同?

很多企业有出口业务&#xff0c;想在互联网上开展全球性网络营销&#xff0c;维基百科往往被认为是开展海外营销的第一站。其作用相当于开展国内网络营销的百度百科&#xff0c;经常有些企业给小马识途营销顾问提供的词条内容就是百度百科的内容&#xff0c;可事实上两个平台的…...

Python小红书旋转验证码识别

本周免费接了一个用户的需求&#xff0c;研究了一下小红书旋转验证码。刚开始小瞧了它&#xff0c;觉得它应该没有百度旋转验证码那么难&#xff0c;毕竟图像没有干扰&#xff0c;需要的训练样本就可以很少。然而事情并没有这么简单&#xff0c;所以记录一下。 首先看一下最终…...

ELK搭建

ELK概述 ELK是elasticsearch Logstash Kibana 这种架构的简写。这是一种日志分平台析的架构&#xff0c; Elasticsearch Logstash filebeat Kibana 这种架构增加了一个filebeat模块。filebeat是一个轻量的日志收集代理&#xff0c;用来部署在客户端&#xff0c;优势是消耗…...

【杂谈】-递归进化:人工智能的自我改进与监管挑战

递归进化&#xff1a;人工智能的自我改进与监管挑战 文章目录 递归进化&#xff1a;人工智能的自我改进与监管挑战1、自我改进型人工智能的崛起2、人工智能如何挑战人类监管&#xff1f;3、确保人工智能受控的策略4、人类在人工智能发展中的角色5、平衡自主性与控制力6、总结与…...

关于iview组件中使用 table , 绑定序号分页后序号从1开始的解决方案

问题描述&#xff1a;iview使用table 中type: "index",分页之后 &#xff0c;索引还是从1开始&#xff0c;试过绑定后台返回数据的id, 这种方法可行&#xff0c;就是后台返回数据的每个页面id都不完全是按照从1开始的升序&#xff0c;因此百度了下&#xff0c;找到了…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!

一、引言 在数据驱动的背景下&#xff0c;知识图谱凭借其高效的信息组织能力&#xff0c;正逐步成为各行业应用的关键技术。本文聚焦 Spring Boot与Neo4j图数据库的技术结合&#xff0c;探讨知识图谱开发的实现细节&#xff0c;帮助读者掌握该技术栈在实际项目中的落地方法。 …...

企业如何增强终端安全?

在数字化转型加速的今天&#xff0c;企业的业务运行越来越依赖于终端设备。从员工的笔记本电脑、智能手机&#xff0c;到工厂里的物联网设备、智能传感器&#xff0c;这些终端构成了企业与外部世界连接的 “神经末梢”。然而&#xff0c;随着远程办公的常态化和设备接入的爆炸式…...

算法笔记2

1.字符串拼接最好用StringBuilder&#xff0c;不用String 2.创建List<>类型的数组并创建内存 List arr[] new ArrayList[26]; Arrays.setAll(arr, i -> new ArrayList<>()); 3.去掉首尾空格...

Java + Spring Boot + Mybatis 实现批量插入

在 Java 中使用 Spring Boot 和 MyBatis 实现批量插入可以通过以下步骤完成。这里提供两种常用方法&#xff1a;使用 MyBatis 的 <foreach> 标签和批处理模式&#xff08;ExecutorType.BATCH&#xff09;。 方法一&#xff1a;使用 XML 的 <foreach> 标签&#xff…...

免费PDF转图片工具

免费PDF转图片工具 一款简单易用的PDF转图片工具&#xff0c;可以将PDF文件快速转换为高质量PNG图片。无需安装复杂的软件&#xff0c;也不需要在线上传文件&#xff0c;保护您的隐私。 工具截图 主要特点 &#x1f680; 快速转换&#xff1a;本地转换&#xff0c;无需等待上…...

Linux nano命令的基本使用

参考资料 GNU nanoを使いこなすnano基础 目录 一. 简介二. 文件打开2.1 普通方式打开文件2.2 只读方式打开文件 三. 文件查看3.1 打开文件时&#xff0c;显示行号3.2 翻页查看 四. 文件编辑4.1 Ctrl K 复制 和 Ctrl U 粘贴4.2 Alt/Esc U 撤回 五. 文件保存与退出5.1 Ctrl …...

FFmpeg:Windows系统小白安装及其使用

一、安装 1.访问官网 Download FFmpeg 2.点击版本目录 3.选择版本点击安装 注意这里选择的是【release buids】&#xff0c;注意左上角标题 例如我安装在目录 F:\FFmpeg 4.解压 5.添加环境变量 把你解压后的bin目录&#xff08;即exe所在文件夹&#xff09;加入系统变量…...