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

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

alt

题图来自 Rust vs Go 2023[1]


81. Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x . Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

按规则取整

package main

import (
 "fmt"
 "math"
)

func round(x float64) int {
 y := int(math.Floor(x + 0.5))
 return y
}

func main() {
 for _, x := range []float64{-1.1-0.9-0.5-0.10.0.10.50.91.1} {
  fmt.Printf("%5.1f %5d\n", x, round(x))
 }
}
 -1.1    -1
 -0.9    -1
 -0.5     0
 -0.1     0
  0.0     0
  0.1     0
  0.5     1
  0.9     1
  1.1     1

fn main() {
    let x : f64 = 2.71828;
    let y = x.round() as i64;
    
    println!("{} {}", x, y);
}

2.71828 3


82. Count substring occurrences

统计子字符串出现次数

package main

import (
 "fmt"
 "strings"
)

func main() {
 s := "Romaromamam"
 t := "mam"

 x := strings.Count(s, t)

 fmt.Println(x)
}

1


fn main() {
    let s = "lorem ipsum lorem ipsum lorem ipsum lorem ipsum";
    let t = "ipsum";

    let c = s.matches(t).count();

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

Disjoint matches: overlapping occurrences are not counted.

4 occurrences


83. Regex with character repetition

Declare regular expression r matching strings "http", "htttp", "httttp", etc.

正则表达式匹配重复字符

package main

import (
 "fmt"
 "regexp"
)

func main() {
 r := regexp.MustCompile("htt+p")

 for _, s := range []string{
  "hp",
  "htp",
  "http",
  "htttp",
  "httttp",
  "htttttp",
  "htttttp",
  "word htttp in a sentence",
 } {
  fmt.Println(s, "=>", r.MatchString(s))
 }
}
hp => false
htp => false
http => true
htttp => true
httttp => true
htttttp => true
htttttp => true
word htttp in a sentence => true

extern crate regex;
use regex::Regex;

fn main() {
    let r = Regex::new(r"htt+p").unwrap();
    
    assert!(r.is_match("http"));
    assert!(r.is_match("htttp"));
    assert!(r.is_match("httttp"));
}

84. Count bits set in integer binary representation

Count number c of 1s in the integer i in base 2.

E.g. i=6 → c=2

计算十进制整型的二进制表示中 1的个数

package main

import "fmt"

func PopCountUInt64(i uint64) (c int) {
 // bit population count, see
 // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
 i -= (i >> 1) & 0x5555555555555555
 i = (i>>2)&0x3333333333333333 + i&0x3333333333333333
 i += i >> 4
 i &= 0x0f0f0f0f0f0f0f0f
 i *= 0x0101010101010101
 return int(i >> 56)
}

func PopCountUInt32(i uint32) (n int) {
 // bit population count, see
 // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
 i -= (i >> 1) & 0x55555555
 i = (i>>2)&0x33333333 + i&0x33333333
 i += i >> 4
 i &= 0x0f0f0f0f
 i *= 0x01010101
 return int(i >> 24)
}

func main() {
 for i := uint64(0); i < 16; i++ {
  c := PopCountUInt64(i)
  fmt.Printf("%4d %04[1]b %d\n", i, c)
 }

 for i := uint32(0); i < 16; i++ {
  c := PopCountUInt32(i)
  fmt.Printf("%4d %04[1]b %d\n", i, c)
 }
}
   0 0000 0
   1 0001 1
   2 0010 1
   3 0011 2
   4 0100 1
   5 0101 2
   6 0110 2
   7 0111 3
   8 1000 1
   9 1001 2
  10 1010 2
  11 1011 3
  12 1100 2
  13 1101 3
  14 1110 3
  15 1111 4
   0 0000 0
   1 0001 1
   2 0010 1
   3 0011 2
   4 0100 1
   5 0101 2
   6 0110 2
   7 0111 3
   8 1000 1
   9 1001 2
  10 1010 2
  11 1011 3
  12 1100 2
  13 1101 3
  14 1110 3
  15 1111 4

This was useful only before go 1.9. See math/bits.OnesCount instead

or

package main

import (
 "fmt"
 "math/bits"
)

func main() {
 for i := uint(0); i < 16; i++ {
  c := bits.OnesCount(i)
  fmt.Printf("%4d %04[1]b %d\n", i, c)
 }
}

   0 0000 0
   1 0001 1
   2 0010 1
   3 0011 2
   4 0100 1
   5 0101 2
   6 0110 2
   7 0111 3
   8 1000 1
   9 1001 2
  10 1010 2
  11 1011 3
  12 1100 2
  13 1101 3
  14 1110 3
  15 1111 4

fn main() {
    println!("{}"6usize.count_ones())
}

2


85. Check if integer addition will overflow

检查两个整型相加是否溢出

package main

import (
 "fmt"
 "math"
)

func willAddOverflow(a, b int64) bool {
 return a > math.MaxInt64-b
}

func main() {

 fmt.Println(willAddOverflow(111111111111111112))

}

false


fn adding_will_overflow(x: usize, y: usize) -> bool {
    x.checked_add(y).is_none()
}

fn main() {
    {
        let (x, y) = (23456789012345);

        let overflow = adding_will_overflow(x, y);

        println!(
            "{} + {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (23456789019012345678);

        let overflow = adding_will_overflow(x, y);

        println!(
            "{} + {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (23456789012349012345678901);

        let overflow = adding_will_overflow(x, y);

        println!(
            "{} + {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (2345678901234567890123456789012345);

        let overflow = adding_will_overflow(x, y);

        println!(
            "{} + {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (123456789012345678909012345678901234567);

        let overflow = adding_will_overflow(x, y);

        println!(
            "{} + {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
}

2345678 + 9012345 doesn't overflow
2345678901 + 9012345678 doesn't overflow
2345678901234 + 9012345678901 doesn't overflow
23456789012345678 + 90123456789012345 doesn't overflow
12345678901234567890 + 9012345678901234567 overflows

86. Check if integer multiplication will overflow

检查整型相乘是否溢出

package main

import (
 "fmt"
)

func multiplyWillOverflow(x, y uint64) bool {
 if x <= 1 || y <= 1 {
  return false
 }
 d := x * y
 return d/y != x
}

func main() {
 {
  var x, y uint64 = 23456789
  if multiplyWillOverflow(x, y) {
   fmt.Println(x, "*", y, "overflows")
  } else {
   fmt.Println(x, "*", y, "doesn't overflow")
  }
 }
 {
  var x, y uint64 = 23456789012345
  if multiplyWillOverflow(x, y) {
   fmt.Println(x, "*", y, "overflows")
  } else {
   fmt.Println(x, "*", y, "doesn't overflow")
  }
 }
 {
  var x, y uint64 = 23456789019012345678
  if multiplyWillOverflow(x, y) {
   fmt.Println(x, "*", y, "overflows")
  } else {
   fmt.Println(x, "*", y, "doesn't overflow")
  }
 }
}

2345 * 6789 doesn't overflow
2345678 * 9012345 doesn'
t overflow
2345678901 * 9012345678 overflows

fn main() {
    {
        let (x, y) = (23456789);

        let overflow = multiply_will_overflow(x, y);

        println!(
            "{} * {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (23456789012345);

        let overflow = multiply_will_overflow(x, y);

        println!(
            "{} * {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
    {
        let (x, y) = (23456789019012345678);

        let overflow = multiply_will_overflow(x, y);

        println!(
            "{} * {} {}",
            x,
            y,
            if overflow {
                "overflows"
            } else {
                "doesn't overflow"
            }
        );
    }
}

fn multiply_will_overflow(x: i64, y: i64) -> bool {
    x.checked_mul(y).is_none()
}
2345 * 6789 doesn't overflow
2345678 * 9012345 doesn't overflow
2345678901 * 9012345678 overflows

87. Stop program

Exit immediately.
If some extra cleanup work is executed by the program runtime (not by the OS itself), describe it.

停止程序,立即退出。

package main

import "os"

func main() {

 os.Exit(1)

 print(2222)
}


fn main() {
    std::process::exit(1);
    println!("42");
}

88. Allocate 1M bytes

分配1M内存

package main

import "fmt"

func main() {
 buf := make([]byte1000000)

 for i, b := range buf {
  if b != 0 {
   fmt.Println("Found unexpected value", b, "at position", i)
  }
 }
 fmt.Println("Buffer was correctly initialized with zero values.")
}

Buffer was correctly initialized with zero values.


fn main() {
    let buf: Vec<u8> = Vec::with_capacity(1024 * 1024);
    println!("{:?}", buf.capacity());
}

1048576


89. Handle invalid argument

处理无效参数

package main

import "fmt"

// NewSquareMatrix creates a N-by-N matrix
func NewSquareMatrix(N int) ([][]float64, error) {
 if N < 0 {
  return nil, fmt.Errorf("Invalid size %d: order cannot be negative", N)
 }
 matrix := make([][]float64, N)
 for i := range matrix {
  matrix[i] = make([]float64, N)
 }
 return matrix, nil
}

func main() {
 N1 := 3
 matrix1, err1 := NewSquareMatrix(N1)
 if err1 == nil {
  fmt.Println(matrix1)
 } else {
  fmt.Println(err1)
 }

 N2 := -2
 matrix2, err2 := NewSquareMatrix(N2)
 if err2 == nil {
  fmt.Println(matrix2)
 } else {
  fmt.Println(err2)
 }
}

[[0 0 0] [0 0 0] [0 0 0]]
Invalid size -2: order cannot be negative

#[derive(Debug, PartialEq, Eq)]
enum CustomError { InvalidAnswer }

fn do_stuff(x: i32) -> Result<i32, CustomError> {
    if x != 42 {
%2

90. Read-only outside

外部只读

type Foo struct {
 x int
}

func (f *Foo) X() int {
 return f.x
}
x is private, because it is not capitalized.
(*Foo).X is a public getter (a read accessor).

struct Foo {
    x: usize
}

impl Foo {
    pub fn new(x: usize) -> Self {
        Foo { x }
    }

    pub fn x<'a>(&'a self) -> &'a usize {
        &self.x
    }
}

91. Load JSON file into struct

json转结构体

package main

import "fmt"
import "io/ioutil"
import "encoding/json"

func readJSONFile() error {
 var x Person

 buffer, err := ioutil.ReadFile(filename)
 if err != nil {
  return err
 }
 err = json.Unmarshal(buffer, &x)
 if err != nil {
  return err
 }

 fmt.Println(x)
 return nil
}

func main() {
 err := readJSONFile()
 if err != nil {
  panic(err)
 }
}

type Person struct {
 FirstName string
 Age       int
}

const filename = "/tmp/data.json"

func init() {
 err := ioutil.WriteFile(filename, []byte(`
  {
   "FirstName":"Napoléon",
   "Age": 51 
  }`
), 0644)
 if err != nil {
  panic(err)
 }
}

{Napoléon 51}

or

package main

import (
 "encoding/json"
 "fmt"
 "io/ioutil"
 "os"
)

func readJSONFile() error {
 var x Person

 r, err := os.Open(filename)
 if err != nil {
  return err
 }
 decoder := json.NewDecoder(r)
 err = decoder.Decode(&x)
 if err != nil {
  return err
 }

 fmt.Println(x)
 return nil
}

func main() {
 err := readJSONFile()
 if err != nil {
  panic(err)
 }
}

type Person struct {
 FirstName string
 Age       int
}

const filename = "/tmp/data.json"

func init() {
 err := ioutil.WriteFile(filename, []byte(`
  {
   "FirstName":"Napoléon",
   "Age": 51 
  }`
), 0644)
 if err != nil {
  panic(err)
 }
}

{Napoléon 51}


#[macro_use] extern crate serde_derive;
extern crate serde_json;
use std::fs::File;
let x = ::serde_json::from_reader(File::open("data.json")?)?;

92. Save object into JSON file

将json对象写入文件

package main

import "fmt"
import "io/ioutil"
import "encoding/json"

func writeJSONFile() error {
 x := Person{
  FirstName: "Napoléon",
  Age:       51,
 }

 buffer, err := json.MarshalIndent(x, """  ")
 if err != nil {
  return err
 }
 return ioutil.WriteFile(filename, buffer, 0644)
}

func main() {
 err := writeJSONFile()
 if err != nil {
  panic(err)
 }
 fmt.Println("Done.")
}

type Person struct {
 FirstName string
 Age       int
}

const filename = "/tmp/data.json"

json.MarshalIndent is more human-readable than json.Marshal.

Done.


extern crate serde_json;
#[macro_use] extern crate serde_derive;

use std::fs::File;
::serde_json::to_writer(&File::create("data.json")?, &x)?

93. Pass a runnable procedure as parameter

Implement procedure control which receives one parameter f, and runs f.

以函数作为参数

package main

import "fmt"

func main() {
 control(greet)
}

func control(f func()) {
 fmt.Println("Before f")
 f()
 fmt.Println("After f")
}

func greet() {
 fmt.Println("Hello, developers")
}

Go supports first class functions, higher-order functions, user-defined function types, function literals, and closures.

Before f
Hello, developers
After f

fn control(f: impl Fn()) {
    f();
}

fn hello() {
    println!("Hello,");
}

fn main() {
    control(hello);
    control(|| { println!("Is there anybody in there?"); });
}

Hello,
Is there anybody in there?

94. Print type of variable

打印变量的类型

package main

import (
 "fmt"
 "os"
 "reflect"
)

func main() {
 var x interface{}

 x = "Hello"
 fmt.Println(reflect.TypeOf(x))

 x = 4
 fmt.Println(reflect.TypeOf(x))

 x = os.NewFile(0777"foobar.txt")
 fmt.Println(reflect.TypeOf(x))
}

string
int
*os.File

or

package main

import (
 "fmt"
 "os"
)

func main() {
 var x interface{}

 x = "Hello"
 fmt.Printf("%T", x)
 fmt.Println()

 x = 4
 fmt.Printf("%T", x)
 fmt.Println()

 x = os.NewFile(0777"foobar.txt")
 fmt.Printf("%T", x)
 fmt.Println()
}
string
int
*os.File

#![feature(core_intrinsics)]

fn type_of<T>(_: &T) -> String {
    format!("{}", std::intrinsics::type_name::<T>())
}

fn main() {
    let x: i32 = 1;
    println!("{}", type_of(&x));
}

i32


95. Get file size

获取文件的大小

package main

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

func main() {
 err := printSize("file.txt")
 if err != nil {
  panic(err)
 }
}

func printSize(path string) error {
 info, err := os.Stat(path)
 if err != nil {
  return err
 }
 x := info.Size()

 fmt.Println(x)
 return nil
}

func init() {
 // The file will only contains the characters "Hello", no newlines.
 buffer := []byte("Hello")
 err := ioutil.WriteFile("file.txt", buffer, 0644)
 if err != nil {
  panic(err)
 }
}

5


use std::fs;

fn filesize(path: &str) -> Result<u64, std::io::Error> {
    let x = fs::metadata(path)?.len();
    Ok(x)
}

fn main() {
    let path = "/etc/hosts";
    let x = filesize(path);
    println!("{}: {:?} bytes", path, x.unwrap());
}

/etc/hosts: 150 bytes

or

use std::path::Path;

fn filesize(path: &std::path::Path) -> Result<u64, std::io::Error> {
    let x = path.metadata()?.len();
    Ok(x)
}

fn main() {
    let path = Path::new("/etc/hosts");
    let x = filesize(path);
    println!("{:?}: {:?} bytes", path, x.unwrap());
}

"/etc/hosts": 150 bytes


96. Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

检查两个字符串前缀是否一致

package main

import (
 "fmt"
 "strings"
)

func check(s, prefix string) {

 b := strings.HasPrefix(s, prefix)

 if b {
  fmt.Println(s, "starts with", prefix)
 } else {
  fmt.Println(s, "doesn't start with", prefix)
 }
}

func main() {
 check("bar""foo")
 check("foobar""foo")
}

bar doesn't start with foo
foobar starts with foo

fn main() {
    let s = "bananas";
    let prefix = "bana";

    let b = s.starts_with(prefix);

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

true


97. Check string suffix

Set boolean b to true if string s ends with string suffix, false otherwise.

检查字符串后缀

package main

import (
 "fmt"
 "strings"
)

func check(s, suffix string) {

 b := strings.HasSuffix(s, suffix)

 if b {
  fmt.Println(s, "ends with", suffix)
 } else {
  fmt.Println(s, "doesn't end with", suffix)
 }
}

func main() {
 check("foo""bar")
 check("foobar""bar")
}
foo doesn't end with bar
foobar ends with bar

fn main() {
    let s = "bananas";
    let suffix = "nas";

    let b = s.ends_with(suffix);

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

true


98. Epoch seconds to date object

Convert a timestamp ts (number of seconds in epoch-time) to a date with time d. E.g. 0 -> 1970-01-01 00:00:00

时间戳转日期

package main

import (
 "fmt"
 "time"
)

func main() {
 ts := int64(1451606400)
 d := time.Unix(ts, 0)

 fmt.Println(d)
}

2016-01-01 00:00:00 +0000 UTC


extern crate chrono;
use chrono::prelude::*;

fn main() {
    let ts = 1451606400;
    let d = NaiveDateTime::from_timestamp(ts, 0);
    println!("{}", d);
}

2016-01-01 00:00:00


99. Format date YYYY-MM-DD

Assign to string x the value of fields (year, month, day) of date d, in format YYYY-MM-DD.

时间格式转换

package main

import (
 "fmt"
 "time"
)

func main() {
 d := time.Now()
 x := d.Format("2006-01-02")
 fmt.Println(x)

 // The output may be "2009-11-10" because the Playground's clock is fixed in the past.
}

2009-11-10


extern crate chrono;

use chrono::prelude::*;

fn main() {
    println!("{}", Utc::today().format("%Y-%m-%d"))
}

2021-07-17


100. Sort by a comparator

Sort elements of array-like collection items, using a comparator c.

根据某个字段排序

package main

import "fmt"
import "sort"

type Item struct {
 label string
 p     int
 lang  string
}

// c returns true if x is "inferior to" y (in a custom way)
func c(x, y Item) bool {
 return x.p < y.p
}

type ItemCSorter []Item

func (s ItemCSorter) Len() int           { return len(s) }
func (s ItemCSorter) Less(i, j int) bool { return c(s[i], s[j]) }
func (s ItemCSorter) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }

func sortItems(items []Item) {
 sorter := ItemCSorter(items)
 sort.Sort(sorter)
}

func main() {
 items := []Item{
  {"twelve"12"english"},
  {"six"6"english"},
  {"eleven"11"english"},
  {"zero"0"english"},
  {"two"2"english"},
 }
 fmt.Println("Unsorted: ", items)
 sortItems(items)
 fmt.Println("Sorted: ", items)
}

c has type func(Item, Item) bool.

Unsorted:  [{twelve 12 english} {six 6 english} {eleven 11 english} {zero 0 english} {two 2 english}]
Sorted:  [{zero 0 english} {two 2 english} {six 6 english} {eleven 11 english} {twelve 12 english}]

or

package main

import "fmt"
import "sort"

type Item struct {
 label string
 p     int
 lang  string
}

type ItemsSorter struct {
 items []Item
 c     func(x, y Item) bool
}

func (s ItemsSorter) Len() int           { return len(s.items) }
func (s ItemsSorter) Less(i, j int) bool { return s.c(s.items[i], s.items[j]) }
func (s ItemsSorter) Swap(i, j int)      { s.items[i], s.items[j] = s.items[j], s.items[i] }

func sortItems(items []Item, c func(x, y Item) bool) {
 sorter := ItemsSorter{
  items,
  c,
 }
 sort.Sort(sorter)
}

func main() {
 items := []Item{
  {"twelve"12"english"},
  {"six"6"english"},
  {"eleven"11"english"},
  {"zero"0"english"},
  {"two"2"english"},
 }
 fmt.Println("Unsorted: ", items)

 c := func(x, y Item) bool {
  return x.p < y.p
 }
 sortItems(items, c)

 fmt.Println("Sorted: ", items)
}

ItemsSorter contains c, which can be any comparator decided at runtime.

Unsorted:  [{twelve 12 english} {six 6 english} {eleven 11 english} {zero 0 english} {two 2 english}]
Sorted:  [{zero 0 english} {two 2 english} {six 6 english} {eleven 11 english} {twelve 12 english}]

or

package main

import "fmt"
import "sort"

type Item struct {
 label string
 p     int
 lang  string
}

// c returns true if x is "inferior to" y (in a custom way)
func c(x, y Item) bool {
 return x.p < y.p
}

func main() {
 items := []Item{
  {"twelve"12"english"},
  {"six"6"english"},
  {"eleven"11"english"},
  {"zero"0"english"},
  {"two"2"english"},
 }
 fmt.Println("Unsorted: ", items)
 
 sort.Slice(items, func(i, j int) bool {
  return c(items[i], items[j])
 })
 
 fmt.Println("Sorted: ", items)
}

Since Go 1.8, a single func parameter is sufficient to sort a slice.

Unsorted:  [{twelve 12 english} {six 6 english} {eleven 11 english} {zero 0 english} {two 2 english}]
Sorted:  [{zero 0 english} {two 2 english} {six 6 english} {eleven 11 english} {twelve 12 english}]

fn main() {
    let mut items = [17523];
    items.sort_by(i32::cmp);
    println!("{:?}", items);
}

[1, 2, 3, 5, 7]


参考资料

[1]

Rust vs Go 2023: https://arkiana.com/rust-vs-go/

本文由 mdnice 多平台发布

相关文章:

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

题图来自 Rust vs Go 2023[1] 81. Round floating point number to integer Declare integer y and initialize it with the rounded value of floating point number x . Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity). 按规…...

Flutter 扩展函数项目实用之封装SizedBox

Flutter里扩展函数可以用简化代码写法&#xff0c;关键字为extension&#xff0c;伪代码写法如下&#xff1a; extension 扩展类名 on 扩展类型 { //扩展方法 } 在Flutter页面里实现控件间距会常用到SizedBox&#xff0c;可使用扩展函数封装来达到简化代码的目的&#xff0…...

EMC学习笔记(二十)EMC常用元件简单介绍(二)

EMC常用元件简单介绍&#xff08;二&#xff09; 1.瞬态抑制二极管&#xff08;TVS&#xff09;2.气体放电管3.半导体放电管 电磁兼容性元件是解决电磁干扰发射和电磁敏感度问题的关键,正确选择和使用这些元件是做好电磁兼容性设计的前提。由于每一种电子元件都有它各自的特性,…...

基本排序算法

目录 一&#xff0c;插入排序 二&#xff0c;希尔排序 三&#xff0c;选择排序 四&#xff0c;冒泡排序 五&#xff0c;快排 5.1 Hoare法 5.2 挖坑法 5.3 指针法 5.4 非递归写法 六&#xff0c;归并排序 6.1 递归 6.2 非递归 一&#xff0c;插入排序 基本思想&…...

python调用百度ai将图片/pdf识别为表格excel

python调用百度ai将图片识别为表格excel 表格文字识别(异步接口)图片转excel 表格文字识别V2图片/pdf转excel通用 表格文字识别(异步接口) 图片转excel 百度ai官方文档&#xff1a;https://ai.baidu.com/ai-doc/OCR/Ik3h7y238 使用的是表格文字识别(异步接口)&#xff0c;同步…...

Ansible最佳实践之Playbook管理滚动更新

写在前面 理解不足小伙伴帮忙指正 傍晚时分&#xff0c;你坐在屋檐下&#xff0c;看着天慢慢地黑下去&#xff0c;心里寂寞而凄凉&#xff0c;感到自己的生命被剥夺了。当时我是个年轻人&#xff0c;但我害怕这样生活下去&#xff0c;衰老下去。在我看来&#xff0c;这是比死亡…...

基于Citespace、vosviewer、R语言的文献计量学可视化分析及SCI论文高效写作方法教程

详情点击链接&#xff1a;基于Citespace、vosviewer、R语言的文献计量学可视化分析技术及全流程文献可视化SCI论文高效写作方法 前言 文献计量学是指用数学和统计学的方法&#xff0c;定量地分析一切知识载体的交叉科学。它是集数学、统计学、文献学为一体&#xff0c;注重量…...

【MATLAB】GM(1,1) 灰色预测模型及算法

一、灰色预测模型概念 灰色预测是一种对含有不确定因素的系统进行预测的方法。 灰色预测通过鉴别系统因素之间发展趋势的相异程度&#xff0c;即进行关联分析&#xff0c;并对原始数据进行生成处理来寻找系统变动的规律&#xff0c;生成有较强规律性的数据序列&#xff0c;然后…...

Go重写Redis中间件 - Go实现Redis协议解析器

Go实现Redis协议解析器 Redis网络协议详解 在解决完通信后,下一步就是搞清楚 Redis 的协议-RESP协议,其实就是一套类似JSON、Protocol Buffers的序列化协议,也就是我们的客户端和服务端通信的协议 RESP定义了5种格式 简单字符串(Simple String) : 服务器用来返回简单的结…...

海外抖音Tiktok强势来袭,有些人半年赚别人十倍工资

TikTok作为一款流行的短视频社交应用程序&#xff0c;确实在全球范围内取得了很大的成功。许多人通过在TikTok上分享有趣、创意或有吸引力的视频内容&#xff0c;获得了广泛的关注和认可。一些用户甚至能够通过TikTok赚取高额的收入&#xff0c;远远超过传统职业所能获得的工资…...

devDept Eyeshot 2024 预告-Update-Crack

即将发布的版本 开发商在一个动态的环境中运作&#xff0c;事情可能会发生变化。本页提供的信息旨在概述 devDept 软件产品的总体方向。它仅供参考&#xff0c;不应作为做出任何决定性的依据。devDept Eyeshot 2024软件产品描述的任何特性或功能的开发、发布和时间安排仍由 dev…...

教雅川学缠论05-线段

线段需要满足下面4个条件&#xff1a; 1.是由3条笔&#xff0c;或者3条以上组成&#xff0c;同笔一样&#xff0c;线段也是有方向的 2.如果线段起始于向上笔&#xff0c;则终止与向上笔&#xff08;一定不会终止与向下笔&#xff09; 3.如果线段起始于向下笔&#xff0c;则终止…...

SpringBoot 配置⽂件

1.配置文件作用 整个项⽬中所有重要的数据都是在配置⽂件中配置的&#xff0c;⽐如&#xff1a; 数据库的连接信息&#xff08;包含⽤户名和密码的设置&#xff09;&#xff1b;项⽬的启动端⼝&#xff1b;第三⽅系统的调⽤秘钥等信息&#xff1b;⽤于发现和定位问题的普通⽇…...

基于Python的电影票房爬取与可视化系统的设计与实现

博主介绍&#xff1a;✌全网粉丝30W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专…...

Packet Tracer – 配置系统日志和 NTP

Packet Tracer – 配置系统日志和 NTP 目标 第 1 部分&#xff1a;配置系统日志服务 第 2 部分&#xff1a;生成日志记录事件 第 3 部分&#xff1a;手动设置交换机时钟 第 4 部分&#xff1a;配置 NTP 服务 第 5 部分&#xff1a;验证带时间戳的日志 拓扑图 场景 在本…...

TypeScript 联合类型,类型推断,类型断言

联合类型 取值可以为多种类型中的一个 function func(str: number | string):void{}类型断言 当变量需要调用某属性的时候&#xff0c;有不确定当前的类型是什么&#xff0c;可以使用类型断言&#xff1b; 类型断言的两种方式&#xff1a; 1&#xff0c;<类型> 变量名…...

到底叫 集合还是数组还是list还是列表?

1 总体上可以将数据结构分为数组和集合两种&#xff0c;而列表是一个泛指 数组&#xff1a;在Java中&#xff0c;数组是一种基本数据类型&#xff0c;可以用来存储同一类型的多个元素&#xff0c;数组的长度是固定的。例如&#xff1a;int[] arr new int[10];List&#xff1a…...

LBERT论文详解

论文地址&#xff1a;https://arxiv.org/abs/2105.07148 代码地址&#xff1a;https://github.com/liuwei1206/LEBERT 模型创新 LEBRT采用句子中的词语对&#xff08;论文中称为Char-Word Pair&#xff09;的特征作为输入作者设计Lexicon adapter&#xff0c;在BERT的中间某一…...

C++终止cin输入while循环时多读取^Z或^D的问题

原代码&#xff1a; istream& operator>>(istream& is, map<string, int>&mm) {string ss"";int ii0;is >> ss>>ii;mm[ss]ii;return is; }int main() {map<string,int>msi;while(cin>>msi);return 0; } 问题&…...

c#[WebMethod]方法接收前端传入的JsonArray的方法

一、第一种方法&#xff1a;可以这样接收前端传入的jsonArray字符串到一个类的数组中&#xff0c;然后遍历该数组取值 这种方法需要创建PointConfig类 class PointConfig{public string ptcrossing { get; set; }public string ptcrossingId { get; set; }public string camId …...

ZjDroid命令大全:从DEX内存dump到Lua脚本注入的完整教程

ZjDroid命令大全&#xff1a;从DEX内存dump到Lua脚本注入的完整教程 【免费下载链接】ZjDroid Android app dynamic reverse tool based on Xposed framework. 项目地址: https://gitcode.com/gh_mirrors/zj/ZjDroid ZjDroid是一款基于Xposed框架的Android应用动态逆向分…...

AI时代程序员职业发展与个人创业可行性研究报告

一、行业宏观变革&#xff08;2026核心趋势数据佐证&#xff09; 1.1 开发范式已彻底重构&#xff08;行业不可逆拐点&#xff09; 2026年正式进入AI Agent智能体开发时代&#xff0c;传统CRUD编码价值持续崩塌。 核心权威数据&#xff1a; Gartner预测&#xff1a;2026年75%企…...

一次搞懂内存取证:用Volatility3和Cobalt Strike分析工具复现VNCTF‘来一把紧张刺激的CS’

实战内存取证&#xff1a;从Volatility3到Cobalt Strike信标分析全解析 在网络安全事件响应中&#xff0c;内存取证往往是发现高级威胁的最后一道防线。当攻击者使用文件无落地的技术时&#xff0c;传统的磁盘取证可能一无所获&#xff0c;而内存中却保留着攻击行为的完整痕迹。…...

3步解锁网易云音乐NCM加密:让音乐真正属于你

3步解锁网易云音乐NCM加密&#xff1a;让音乐真正属于你 【免费下载链接】ncmdump 项目地址: https://gitcode.com/gh_mirrors/ncmd/ncmdump 还在为下载的网易云音乐只能在特定客户端播放而烦恼吗&#xff1f;当你精心收藏的歌曲被NCM格式"锁"在单一平台时&a…...

独立站内容分层:一层给 SEO,一层给 GEO

你的内容在喂两个完全不同的"阅读者" 你的博客文章&#xff0c;从来都不只有一个读者。 传统认知里&#xff0c;独立站内容的读者只有两类&#xff1a;真人访客和搜索引擎爬虫。SEO 优化的一切工作&#xff0c;本质上都是在讨好后者&#xff0c;顺带服务前者。 但…...

从开题到定稿零焦虑:okbiye AI 论文写作,帮你把毕业季的 “大山” 变成坦途

okbiye-免费查重复率aigc检测/开题报告/毕业论文/智能排版/文献综述/AI PPT毕业论文 - Okbiye智能写作https://www.okbiye.com/ai/bylw 毕业季的深夜&#xff0c;宿舍台灯下的屏幕亮着刺眼的光&#xff0c;文档里的字数停留在三位数&#xff0c;而 deadline 正一天天逼近。你是…...

统信UOS浏览器书签同步难题?一招搞定所有新用户默认书签配置

统信UOS浏览器书签批量配置&#xff1a;系统管理员的高效部署指南在企业或教育机构的IT运维工作中&#xff0c;统信UOS作为国产操作系统的代表&#xff0c;其浏览器书签的统一管理常常成为系统管理员面临的挑战。想象一下&#xff0c;每当有新员工入职或学生入学&#xff0c;都…...

国内大学生常用的AI写作辅助平台有哪些?

国内高校学生常用的 AI 写作辅助平台&#xff0c;以本土化全流程工具为主&#xff0c;结合通用大模型与专项功能模块&#xff0c;覆盖选题构思、大纲搭建、初稿撰写、语言润色、降重处理、查重检测及格式排版等关键环节&#xff0c;以下是主流平台详解与对比&#xff1a; 一、本…...

告别漫长等待:UE5.2.1 Windows打包效率优化与插件问题排查指南

告别漫长等待&#xff1a;UE5.2.1 Windows打包效率优化与插件问题排查指南第一次点击"打包项目"按钮时&#xff0c;进度条仿佛被冻结的场景&#xff0c;每个UE5开发者都经历过。尤其当项目规模达到数十GB时&#xff0c;等待时间可能超过一小时——这背后隐藏着引擎底…...

3PEAK思瑞浦 TPA6531-S5TR SOT23-5 运算放大器

特性 供电电压:1.75V至5.5V 偏移电压:1.5mV(最大值) 最大可调工作频率:300kHz&#xff0c;斜率:0.15V/us 轨到轨输入和输出 0.1赫兹至10赫兹电压噪声:1伏峰值 开关电源时无显著输出抖动 低功耗:每通道最大25安培 工作温度范围:-40C至125C...