Rust vs Go:常用语法对比(九)
![alt](https://img-blog.csdnimg.cn/img_convert/266b9b9f05044abd366bfdef599112e1.png)
题图来自 Golang vs Rust - The Race to Better and Ultimate Programming Language
161. Multiply all the elements of a list
Multiply all the elements of the list elements by a constant c
将list中的每个元素都乘以一个数
package main
import (
"fmt"
)
func main() {
const c = 5.5
elements := []float64{2, 4, 9, 30}
fmt.Println(elements)
for i := range elements {
elements[i] *= c
}
fmt.Println(elements)
}
[2 4 9 30]
[11 22 49.5 165]
fn main() {
let elements: Vec<f32> = vec![2.0, 3.5, 4.0];
let c = 2.0;
let elements = elements.into_iter().map(|x| c * x).collect::<Vec<_>>();
println!("{:?}", elements);
}
[4.0, 7.0, 8.0]
162. Execute procedures depending on options
execute bat if b is a program option and fox if f is a program option.
根据选项执行程序
package main
import (
"flag"
"fmt"
"os"
)
func init() {
// Just for testing in the Playground, let's simulate
// the user called this program with command line
// flags -f and -b
os.Args = []string{"program", "-f", "-b"}
}
var b = flag.Bool("b", false, "Do bat")
var f = flag.Bool("f", false, "Do fox")
func main() {
flag.Parse()
if *b {
bar()
}
if *f {
fox()
}
fmt.Println("The end.")
}
func bar() {
fmt.Println("BAR")
}
func fox() {
fmt.Println("FOX")
}
BAR
FOX
The end.
if let Some(arg) = ::std::env::args().nth(1) {
if &arg == "f" {
fox();
} else if &arg = "b" {
bat();
} else {
eprintln!("invalid argument: {}", arg),
}
} else {
eprintln!("missing argument");
}
or
if let Some(arg) = ::std::env::args().nth(1) {
match arg.as_str() {
"f" => fox(),
"b" => box(),
_ => eprintln!("invalid argument: {}", arg),
};
} else {
eprintln!("missing argument");
}
163. Print list elements by group of 2
Print all the list elements, two by two, assuming list length is even.
两个一组打印数组元素
package main
import (
"fmt"
)
func main() {
list := []string{"a", "b", "c", "d", "e", "f"}
for i := 0; i+1 < len(list); i += 2 {
fmt.Println(list[i], list[i+1])
}
}
a b
c d
e f
fn main() {
let list = [1,2,3,4,5,6];
for pair in list.chunks(2) {
println!("({}, {})", pair[0], pair[1]);
}
}
(1, 2)
(3, 4)
(5, 6)
164. Open URL in default browser
Open the URL s in the default browser. Set boolean b to indicate whether the operation was successful.
在默认浏览器中打开链接
import "github.com/skratchdot/open-golang/open"
b := open.Start(s) == nil
or
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
default:
err = fmt.Errorf("unsupported platform")
}
if err != nil {
log.Fatal(err)
}
}
use webbrowser;
webbrowser::open(s).expect("failed to open URL");
165. Last element of list
Assign to variable x the last element of list items.
列表中的最后一个元素
package main
import (
"fmt"
)
func main() {
items := []string{ "what", "a", "mess" }
x := items[len(items)-1]
fmt.Println(x)
}
mess
fn main() {
let items = vec![5, 6, 8, -20, 9, 42];
let x = items[items.len()-1];
println!("{:?}", x);
}
42
or
fn main() {
let items = [5, 6, 8, -20, 9, 42];
let x = items.last().unwrap();
println!("{:?}", x);
}
42
166. Concatenate two lists
Create list ab containing all the elements of list a, followed by all elements of list b.
连接两个列表
package main
import (
"fmt"
)
func main() {
a := []string{"The ", "quick "}
b := []string{"brown ", "fox "}
ab := append(a, b...)
fmt.Printf("%q", ab)
}
["The " "quick " "brown " "fox "]
or
package main
import (
"fmt"
)
func main() {
type T string
a := []T{"The ", "quick "}
b := []T{"brown ", "fox "}
var ab []T
ab = append(append(ab, a...), b...)
fmt.Printf("%q", ab)
}
["The " "quick " "brown " "fox "]
or
package main
import (
"fmt"
)
func main() {
type T string
a := []T{"The ", "quick "}
b := []T{"brown ", "fox "}
ab := make([]T, len(a)+len(b))
copy(ab, a)
copy(ab[len(a):], b)
fmt.Printf("%q", ab)
}
["The " "quick " "brown " "fox "]
fn main() {
let a = vec![1, 2];
let b = vec![3, 4];
let ab = [a, b].concat();
println!("{:?}", ab);
}
[1, 2, 3, 4]
167. Trim prefix
Create string t consisting of string s with its prefix p removed (if s starts with p).
移除前缀
package main
import (
"fmt"
"strings"
)
func main() {
s := "café-society"
p := "café"
t := strings.TrimPrefix(s, p)
fmt.Println(t)
}
-society
fn main() {
{
let s = "pre_thing";
let p = "pre_";
let t = s.trim_start_matches(p);
println!("{}", t);
}
{
// Warning: trim_start_matches removes several leading occurrences of p, if present.
let s = "pre_pre_thing";
let p = "pre_";
let t = s.trim_start_matches(p);
println!("{}", t);
}
}
thing
thing
or
fn main() {
let s = "pre_pre_thing";
let p = "pre_";
let t = if s.starts_with(p) { &s[p.len()..] } else { s };
println!("{}", t);
}
pre_thing
or
fn main() {
{
let s = "pre_thing";
let p = "pre_";
let t = s.strip_prefix(p).unwrap_or_else(|| s);
println!("{}", t);
}
{
// If prefix p is repeated in s, it is removed only once by strip_prefix
let s = "pre_pre_thing";
let p = "pre_";
let t = s.strip_prefix(p).unwrap_or_else(|| s);
println!("{}", t);
}
}
thing
pre_thing
168. Trim suffix
Create string t consisting of string s with its suffix w removed (if s ends with w).
移除后缀
package main
import (
"fmt"
"strings"
)
func main() {
s := "café-society"
w := "society"
t := strings.TrimSuffix(s, w)
fmt.Println(t)
}
café-
fn main() {
let s = "thing_suf";
let w = "_suf";
let t = s.trim_end_matches(w);
println!("{}", t);
let s = "thing";
let w = "_suf";
let t = s.trim_end_matches(w); // s does not end with w, it is left intact
println!("{}", t);
let s = "thing_suf_suf";
let w = "_suf";
let t = s.trim_end_matches(w); // removes several occurrences of w
println!("{}", t);
}
thing
thing
thing
or
fn main() {
let s = "thing_suf";
let w = "_suf";
let t = s.strip_suffix(w).unwrap_or(s);
println!("{}", t);
let s = "thing";
let w = "_suf";
let t = s.strip_suffix(w).unwrap_or(s); // s does not end with w, it is left intact
println!("{}", t);
let s = "thing_suf_suf";
let w = "_suf";
let t = s.strip_suffix(w).unwrap_or(s); // only 1 occurrence of w is removed
println!("{}", t);
}
thing
thing
thing_suf
169. String length
Assign to integer n the number of characters of string s. Make sure that multibyte characters are properly handled. n can be different from the number of bytes of s.
字符串长度
package main
import "fmt"
import "unicode/utf8"
func main() {
s := "Hello, 世界"
n := utf8.RuneCountInString(s)
fmt.Println(n)
}
9
fn main() {
let s = "世界";
let n = s.chars().count();
println!("{} characters", n);
}
2 characters
170. Get map size
Set n to the number of elements stored in mymap.
This is not always equal to the map capacity.
获取map的大小
package main
import "fmt"
func main() {
mymap := map[string]int{"a": 1, "b": 2, "c": 3}
n := len(mymap)
fmt.Println(n)
}
3
use std::collections::HashMap;
fn main() {
let mut mymap: HashMap<&str, i32> = [("one", 1), ("two", 2)].iter().cloned().collect();
mymap.insert("three", 3);
let n = mymap.len();
println!("mymap has {:?} entries", n);
}
mymap has 3 entries
171. Add an element at the end of a list
Append element x to the list s.
在list尾部添加元素
package main
import "fmt"
func main() {
s := []int{1, 1, 2, 3, 5, 8, 13}
x := 21
s = append(s, x)
fmt.Println(s)
}
[1 1 2 3 5 8 13 21]
fn main() {
let mut s = vec![1, 2, 3];
let x = 99;
s.push(x);
println!("{:?}", s);
}
[1, 2, 3, 99]
172. Insert entry in map
Insert value v for key k in map m.
向map中写入元素
package main
import "fmt"
func main() {
m := map[string]int{"one": 1, "two": 2}
k := "three"
v := 3
m[k] = v
fmt.Println(m)
}
map[one:1 three:3 two:2]
use std::collections::HashMap;
fn main() {
let mut m: HashMap<&str, i32> = [("one", 1), ("two", 2)].iter().cloned().collect();
let (k, v) = ("three", 3);
m.insert(k, v);
println!("{:?}", m);
}
{"three": 3, "one": 1, "two": 2}
173. Format a number with grouped thousands
Number will be formatted with a comma separator between every group of thousands.
按千位格式化数字
package main
import (
"fmt"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
// The Playground doesn't work with import of external packages.
// However, you may copy this source and test it on your workstation.
func main() {
p := message.NewPrinter(language.English)
s := p.Sprintf("%d\n", 1000)
fmt.Println(s)
// Output:
// 1,000
}
1,000
or
package main
import (
"fmt"
"github.com/floscodes/golang-thousands"
"strconv"
)
// The Playground takes more time when importing external packages.
// However, you may want to copy this source and test it on your workstation.
func main() {
n := strconv.Itoa(23489)
s := thousands.Separate(n, "en")
fmt.Println(s)
// Output:
// 23,489
}
23,489
use separator::Separatable;
println!("{}", 1000.separated_string());
174. Make HTTP POST request
Make a HTTP request with method POST to URL u
发起http POST请求
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
)
func main() {
contentType := "text/plain"
var body io.Reader
u := "http://" + localhost + "/hello"
response, err := http.Post(u, contentType, body)
check(err)
buffer, err := ioutil.ReadAll(response.Body)
check(err)
fmt.Println("POST response:", response.StatusCode, string(buffer))
response, err = http.Get(u)
check(err)
buffer, err = ioutil.ReadAll(response.Body)
check(err)
fmt.Println("GET response:", response.StatusCode, string(buffer))
}
const localhost = "127.0.0.1:3000"
func init() {
http.HandleFunc("/hello", myHandler)
startServer()
}
func myHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "Refusing request verb %q", r.Method)
return
}
fmt.Fprintf(w, "Hello POST :)")
}
func startServer() {
listener, err := net.Listen("tcp", localhost)
check(err)
go http.Serve(listener, nil)
}
func check(err error) {
if err != nil {
panic(err)
}
}
POST response: 200 Hello Alice (POST)
GET response: 400 Refusing request verb "GET"
or
package main
import (
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
)
func main() {
formValues := url.Values{
"who": []string{"Alice"},
}
u := "http://" + localhost + "/hello"
response, err := http.PostForm(u, formValues)
check(err)
buffer, err := ioutil.ReadAll(response.Body)
check(err)
fmt.Println("POST response:", response.StatusCode, string(buffer))
response, err = http.Get(u)
check(err)
buffer, err = ioutil.ReadAll(response.Body)
check(err)
fmt.Println("GET response:", response.StatusCode, string(buffer))
}
const localhost = "127.0.0.1:3000"
func init() {
http.HandleFunc("/hello", myHandler)
startServer()
}
func myHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "Refusing request verb %q", r.Method)
return
}
fmt.Fprintf(w, "Hello %s (POST)", r.FormValue("who"))
}
func startServer() {
listener, err := net.Listen("tcp", localhost)
check(err)
go http.Serve(listener, nil)
}
func check(err error) {
if err != nil {
panic(err)
}
}
[dependencies]
error-chain = "0.12.4"
reqwest = { version = "0.11.2", features = ["blocking"] }
use error_chain::error_chain;
use std::io::Read;
let client = reqwest::blocking::Client::new();
let mut response = client.post(u).body("abc").send()?;
175. Bytes to hex string
From array a of n bytes, build the equivalent hex string s of 2n digits. Each byte (256 possible values) is encoded as two hexadecimal characters (16 possible values per digit).
字节转十六进制字符串
package main
import (
"encoding/hex"
"fmt"
)
func main() {
a := []byte("Hello")
s := hex.EncodeToString(a)
fmt.Println(s)
}
48656c6c6f
use core::fmt::Write;
fn main() -> core::fmt::Result {
let a = vec![22, 4, 127, 193];
let n = a.len();
let mut s = String::with_capacity(2 * n);
for byte in a {
write!(s, "{:02X}", byte)?;
}
dbg!(s);
Ok(())
}
[src/main.rs:12] s = "16047FC1"
176. Hex string to byte array
From hex string s of 2n digits, build the equivalent array a of n bytes. Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).
十六进制字符串转字节数组
package main
import (
"encoding/hex"
"fmt"
"log"
)
func main() {
s := "48656c6c6f"
a, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
fmt.Println(a)
fmt.Println(string(a))
}
[72 101 108 108 111]
Hello
use hex::FromHex
let a: Vec<u8> = Vec::from_hex(s).expect("Invalid Hex String");
178. Check if point is inside rectangle
Set boolean b to true if if the point with coordinates (x,y) is inside the rectangle with coordinates (x1,y1,x2,y2) , or to false otherwise. Describe if the edges are considered to be inside the rectangle.
检查点是否在矩形内
package main
import (
"fmt"
"image"
)
func main() {
x1, y1, x2, y2 := 1, 1, 50, 100
r := image.Rect(x1, y1, x2, y2)
x, y := 10, 10
p := image.Pt(x, y)
b := p.In(r)
fmt.Println(b)
x, y = 100, 100
p = image.Pt(x, y)
b = p.In(r)
fmt.Println(b)
}
true
false
struct Rect {
x1: i32,
x2: i32,
y1: i32,
y2: i32,
}
impl Rect {
fn contains(&self, x: i32, y: i32) -> bool {
return self.x1 < x && x < self.x2 && self.y1 < y && y < self.y2;
}
}
179. Get center of a rectangle
Return the center c of the rectangle with coördinates(x1,y1,x2,y2)
获取矩形的中心
import "image"
c := image.Pt((x1+x2)/2, (y1+y2)/2)
struct Rectangle {
x1: f64,
y1: f64,
x2: f64,
y2: f64,
}
impl Rectangle {
pub fn center(&self) -> (f64, f64) {
((self.x1 + self.x2) / 2.0, (self.y1 + self.y2) / 2.0)
}
}
fn main() {
let r = Rectangle {
x1: 5.,
y1: 5.,
x2: 10.,
y2: 10.,
};
println!("{:?}", r.center());
}
(7.5, 7.5)
180. List files in directory
Create list x containing the contents of directory d.
x may contain files and subfolders.
No recursive subfolder listing.
列出目录中的文件
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
d := "/"
x, err := ioutil.ReadDir(d)
if err != nil {
log.Fatal(err)
}
for _, f := range x {
fmt.Println(f.Name())
}
}
.dockerenv
bin
dev
etc
home
lib
lib64
proc
root
sys
tmp
tmpfs
usr
var
use std::fs;
fn main() {
let d = "/etc";
let x = fs::read_dir(d).unwrap();
for entry in x {
let entry = entry.unwrap();
println!("{:?}", entry.path());
}
}
or
fn main() {
let d = "/etc";
let x = std::fs::read_dir(d)
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap();
for entry in x {
println!("{:?}", entry.path());
}
}
"/etc/issue.net"
"/etc/bindresvport.blacklist"
"/etc/rc1.d"
"/etc/hostname"
"/etc/xattr.conf"
"/etc/resolv.conf"
"/etc/pam.conf"
"/etc/mke2fs.conf"
"/etc/e2scrub.conf"
"/etc/update-motd.d"
"/etc/terminfo"
"/etc/alternatives"
"/etc/ld.so.cache"
"/etc/networks"
"/etc/profile"
"/etc/debconf.conf"
"/etc/security"
"/etc/.pwd.lock"
"/etc/gai.conf"
"/etc/dpkg"
"/etc/rc3.d"
"/etc/fstab"
"/etc/gshadow"
"/etc/sysctl.conf"
"/etc/rc2.d"
"/etc/selinux"
"/etc/ld.so.conf.d"
"/etc/os-release"
"/etc/libaudit.conf"
"/etc/login.defs"
"/etc/skel"
"/etc/shells"
"/etc/rc4.d"
"/etc/cron.d"
"/etc/default"
"/etc/lsb-release"
"/etc/apt"
"/etc/debian_version"
"/etc/machine-id"
"/etc/deluser.conf"
"/etc/group"
"/etc/legal"
"/etc/rc6.d"
"/etc/init.d"
"/etc/sysctl.d"
"/etc/pam.d"
"/etc/passwd"
"/etc/rc5.d"
"/etc/bash.bashrc"
"/etc/hosts"
"/etc/rc0.d"
"/etc/environment"
"/etc/cron.daily"
"/etc/shadow"
"/etc/ld.so.conf"
"/etc/subgid"
"/etc/opt"
"/etc/logrotate.d"
"/etc/subuid"
"/etc/profile.d"
"/etc/adduser.conf"
"/etc/issue"
"/etc/rmt"
"/etc/host.conf"
"/etc/rcS.d"
"/etc/nsswitch.conf"
"/etc/systemd"
"/etc/kernel"
"/etc/mtab"
"/etc/shadow-"
"/etc/passwd-"
"/etc/subuid-"
"/etc/gshadow-"
"/etc/subgid-"
"/etc/group-"
"/etc/ethertypes"
"/etc/logcheck"
"/etc/gss"
"/etc/bash_completion.d"
"/etc/X11"
"/etc/perl"
"/etc/ca-certificates"
"/etc/protocols"
"/etc/ca-certificates.conf"
"/etc/python2.7"
"/etc/localtime"
"/etc/xdg"
"/etc/timezone"
"/etc/mailcap.order"
"/etc/emacs"
"/etc/ssh"
"/etc/magic.mime"
"/etc/services"
"/etc/ssl"
"/etc/ldap"
"/etc/rpc"
"/etc/mime.types"
"/etc/magic"
"/etc/mailcap"
"/etc/inputrc"
本文由 mdnice 多平台发布
相关文章:
![](https://img-blog.csdnimg.cn/img_convert/266b9b9f05044abd366bfdef599112e1.png)
Rust vs Go:常用语法对比(九)
题图来自 Golang vs Rust - The Race to Better and Ultimate Programming Language 161. Multiply all the elements of a list Multiply all the elements of the list elements by a constant c 将list中的每个元素都乘以一个数 package mainimport ( "fmt")func …...
![](https://www.ngui.cc/images/no-images.jpg)
Typescript 第五章 类和接口(多态,混入,装饰器,模拟final,设计模式)
第五章 类和接口 类是组织和规划代码的方式,是封装的基本单位。 typescript类大量借用了C#的相关理论,支持可见性修饰符,属性初始化语句,多态,装饰器和接口。 不过,由于Typescript将类编译成常规的JavaScri…...
![](https://www.ngui.cc/images/no-images.jpg)
IFNULL()COALESCE()
在 MySQL 中,IFNULL() 函数是可用的,但是请注意它不能直接用于聚合函数的结果。要在聚合函数结果可能为 NULL 的情况下返回特定值,应该使用 COALESCE() 函数而不是 IFNULL() 函数。 以下是代码示例: COALESCE(SUM(pc.CONTRACT_T…...
![](https://www.ngui.cc/images/no-images.jpg)
WPF实战学习笔记23-首页添加功能
首页添加功能 实现ITodoService、IMemoService接口,并在构造函数中初始化。新建ObservableCollection<ToDoDto>、 ObservableCollection<MemoDto>类型的属性,并将其绑定到UI中修改Addtodo、Addmemo函数,将添加功能添加 添加添加…...
![](https://www.ngui.cc/images/no-images.jpg)
OpenCV-Python常用函数汇总
OpenCV Python OpenCV简述显示窗口waitKey():等待按键输入namedWindow():创建窗口destroyWindow() :注销指定窗口destroyAllWindows() 注销全部窗口resizeWindow() 调整窗口尺寸 图像操作imread():读取图像imwrite():保…...
![](https://img-blog.csdnimg.cn/43aec121b1d940e8bfe1df1d89c35f09.png)
Vue-router多级路由
目录 直接通过案例的形式来演示多级路由的用法 文件结构 Banner.vue <template><div class"col-xs-offset-2 col-xs-8"><div class"page-header"><h2>Vue Router Demo</h2></div></div> </template><…...
![](https://img-blog.csdnimg.cn/caf6998baf474352a6c6d166ebda39ca.png)
前端学习--vue2--2--vue指令基础
写在前面: 前置内容 - vue配置 文章目录 插值表达式v-html条件渲染v-show和v-ifv-ifv-if的扩展标签复用组件 v-show v-on /事件v-bind /:属性v-modelv-for 循环元素v-slotv-prev-cloak vue指令只的是带有v-前缀的特殊标签属性 插值表达式 插值表达式{…...
![](https://img-blog.csdnimg.cn/301ea6f1c1c04cb1a71456c5e9e107b8.png)
【Python机器学习】实验03 logstic回归
文章目录 简单分类模型 - 逻辑回归1.1 准备数据1.2 定义假设函数Sigmoid 函数 1.3 定义代价函数1.4 定义梯度下降算法gradient descent(梯度下降) 1.5 绘制决策边界1.6 计算准确率1.7 试试用Sklearn来解决2.1 准备数据(试试第二个例子)2.2 假设函数与前h相同2.3 代价函数与前相…...
![](https://img-blog.csdnimg.cn/f090d55c43d6491882b1d7c7ab1d13fe.png)
面试-杨辉三角python递归实现,二进制转换
杨辉三角 def yang_hui(x,y):xint(x)yint(y)assert x>y,列数不应该大于行数# x 表示行,y表示列if y1 or yx:return 1else:return yang_hui(x-1,y-1)yang_hui(x-1,y)xinput(输入第几行) yinput(输入第几列) resultyang_hui(int(x),int(y)) print(result) #inclu…...
![](https://www.ngui.cc/images/no-images.jpg)
SPEC CPU 2017 x86_64 Ubuntu 22.04 LTS LLVM 16.0.6 编译 intrate intspeed
源码编译llvm 下载源码 yeqiangyeqiang-MS-7B23:~/Downloads/src$ git clone --depth1 -b 7cbf1a2 https://github.com/llvm/llvm-project 正克隆到 llvm-project... warning: 不能发现要克隆的远程分支 7cbf1a2。 fatal: 远程分支 7cbf1a2 在上游 origin 未发现 yeqiangyeqi…...
![](https://www.ngui.cc/images/no-images.jpg)
java备忘录模式
在Java中,备忘录模式(Memento Design Pattern)用于捕获一个对象的内部状态并在该对象之外保存这个状态。备忘录模式允许在后续需要时将对象恢复到之前保存的状态,而不会暴露其内部结构。 备忘录模式包含以下主要角色:…...
![](https://img-blog.csdnimg.cn/450227db002b402bb5ae29526f90eba8.png)
iOS--runtime
什么是Runtime runtime是由C和C、汇编实现的一套API,为OC语言加入了面向对象、运行时的功能运行时(runtime)将数据类型的确定由编译时推迟到了运行时平时编写的OC代码,在程序运行过程中,最终会转换成runtime的C语言代…...
![](https://img-blog.csdnimg.cn/70d0be0e544f46a3b7fcd0377d48107f.png)
06. 管理Docker容器数据
目录 1、前言 2、Docker实现数据管理的方式 2.1、数据卷(Data Volumes) 2.2、数据卷容器(Data Volume Containers) 3、简单示例 3.1、数据卷示例 3.2、数据卷容器示例 1、前言 在生产环境中使用 Docker,一方面…...
![](https://img-blog.csdnimg.cn/f61e310f89194cc1bf1553f3f3b1d0fa.png)
计算机视觉常用数据集介绍
1 MINIST MINIST 数据集应该算是CV里面最早流行的数据了,相当于CV领域的Hello World。该数据包含70000张手写数字图像,其中60000张用于train, 10000张用于test, 并且都有相应的label。图像的尺寸比较小, 为28x28。 数…...
![](https://img-blog.csdnimg.cn/96de3e4352814a5c83451c8185e9b5be.png)
Arcgis画等高线
目录 数据准备绘制等高线3D等高线今天我们将学习如何在ArcGIS中绘制等高线地图。等高线地图是地理信息系统中常见的数据表现形式,它通过等高线将地形起伏展现得一目了然,不仅美观,还能提供重要的地形信息。 数据准备 在开始之前,确保已经准备好了高程数据,它通常以栅格数…...
![](https://img-blog.csdnimg.cn/275526f035b143438189b66bd62b8a55.png)
abp vnext4.3版本托管到iis同时支持http和https协议
在项目上本来一直使用的是http协议,后来因为安全和一些其他原因需要上https协议,如果发布项目之后想同时兼容http和https协议需要更改一下配置信息,下面一起看一下: 1.安装服务器证书 首先你需要先申请一张服务器证书,申请后将证…...
![](https://www.ngui.cc/images/no-images.jpg)
2023年全网电视盒子无线ADB修改桌面(无需ROOT)
前言 1.主要是为了解决电视盒子等安卓设备无法卸载或者停用原始桌面导致无法选用第三方桌面。 解决方案 1.首先自行下载我提供的网盘APK 2.点击打开中国移动云盘 3.不管你是通过U盘还是局域网共享能够让你的电视安装第三方应用,毕竟每个品牌的安装方法不尽相同…...
![](https://www.ngui.cc/images/no-images.jpg)
什么是Java中的Maven?
Java中的Maven,可以简单理解为“一个神奇的工具”,它可以自动帮你管理Java项目的依赖关系,让你不再为手动下载、配置各种库而烦恼。想象一下,你正在写一个Java项目,突然发现需要引入一个名为"第三方库"的模块…...
![](https://www.ngui.cc/images/no-images.jpg)
【C++】总结7
文章目录 函数指针C中类成员的访问权限和继承权限问题定义和声明的区别C中类的静态成员与普通成员的区别是什么?虚函数为什么不能重载为内联函数?对ifdef endif的理解如何在不使用额外空间的情况下,交换两个数? 函数指针 什么是函…...
![](https://img-blog.csdnimg.cn/img_convert/4d703a790ee896927b3942b99cbcfc55.png)
【前端知识】React 基础巩固(四十二)——React Hooks的介绍
React 基础巩固(四十二)——React Hooks的介绍 一、为什么需要Hook? Hook 是 React 16.8 的新增特性,它可以让我们在不编写class的情况下使用state以及其他的React特性(比如生命周期)。 class组件 VS 函数式组件: class的优势…...
![](https://www.ngui.cc/images/no-images.jpg)
adb命令丨adb push命令大全_adb操控手机和指令
【ADB命令】adb push命令总结 adb push命令大全操控手机和指令 运行在 Android 设备上的adb后台进程 执行 adb shell ps | grep adbd ,可以找到该后台进程,windows 请使用 findstr 替代 grep [xuxu:~]$ adb shell ps | grep adbd root 23227 1 6672 8…...
![](https://img-blog.csdnimg.cn/2dc713a7bc3c46afb90320a27d4fed68.png)
【腾讯云 Cloud Studio 实战训练营】沉浸式体验编写一个博客系统
文章目录 前言项目中技术栈新建工作空间登录(注册)Cloud Studio 账号:进入 Cloud Studio 控制台:配置工作空间参数:确认并创建工作空间:项目搭建 配置nuxt 脚手架运行项目报错信息解决错误脚手架运行预览问题 开启博客代码配置lay…...
![](https://www.ngui.cc/images/no-images.jpg)
手机视频聊天分享
在人际互动的手机APP中,增加语音视频聊天功能是一个常见的需求。而现在,更进一步,在某些场景下,我们需要能将自己的手机屏幕分享给他人,或者是观看他人的手机屏幕。那么,这些常见的功能是如何实现的了&…...
![](https://www.ngui.cc/images/no-images.jpg)
神经网络小记-优化器
优化器是深度学习中用于优化神经网络模型的一类算法,其主要作用是根据模型的损失函数来调整模型的参数,使得模型能够更好地拟合训练数据,提高模型的性能和泛化能力。优化器在训练过程中通过不断更新模型的参数,使模型逐步接近最优…...
![](https://img-blog.csdnimg.cn/45aa9af60df1487d919aa8395ee4d059.gif)
200+行代码写一个简易的Qt界面贪吃蛇
照例先演示一下: 一个简单的Qt贪吃蛇,所有的图片都是我自己画的(得意)。 大致的运行逻辑和之前那个200行写一个C小黑窗贪吃蛇差不多,因此在写这个项目的时候,大多情况是在想怎么通过Qt给展现出来。 背景图…...
![](https://img-blog.csdnimg.cn/566ded8de54648968315fc74d442f80d.png)
redis中使用bloomfilter的白名单功能解决缓存穿透问题
一 缓存预热 1.1 缓存预热 将需要的数据提前缓存到缓存redis中,可以在服务启动时候,或者在使用前一天完成数据的同步等操作。保证后续能够正常使用。 1.2 缓存穿透 在redis中,查询redis缓存数据没有内容,接着查询mysql数据库&…...
Spring Boot 2.7.8以后mysql-connector-java与mysql-connector-j
错误信息 如果升级到Spring Boot 2.7.8,可以看到因为找不到mysql-connector-java依赖而出现错误。 配置: <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId>&l…...
![](https://www.ngui.cc/images/no-images.jpg)
03|「如何写好一个 Prompt」
前言 Prompt 文章目录 前言一、通用模板和范式1. 组成2. 要求1)文字描述2)注意标点符号 一、通用模板和范式 1. 组成 指令(角色) 生成主体 额外要求 指令:模型具体完成的任务描述。例如,翻译一段文字&…...
![](https://img-blog.csdnimg.cn/c332a78b30eb4e1cb571844d0fa9a81f.png)
关于提示词 Prompt
Prompt原则 原则1 提供清晰明确的指示 注意在提示词中添加正确的分割符号 prompt """ 请给出下面文本的摘要: <你的文本> """可以指定输出格式,如:Json、HTML提示词中可以提供少量实例,…...
![](https://img-blog.csdnimg.cn/ca8f9edfd4764a0189aeed57b9132eec.png)
【Linux多线程】线程的互斥与同步(附抢票案例代码+讲解)
线程的互斥与同步 💫 概念引入⭐️临界资源(Critical Resource):🌟临界区(Critical Section):✨互斥(Mutex): ⚡️结合代码看互斥☄️ 代码逻辑&a…...
![](/images/no-images.jpg)
大连网站建设怎么做/百度推广登录平台
建議在流覽器中使用Less僅用於開發,或者當您需要動態編譯較少的代碼並且無法做到這一點。這是因為less.js是一個大型的JavaScript檔,並且在用戶可以看到該頁面意味著用戶的延遲之前編譯Less。另外,考慮到移動設備編譯速度會更慢。對於開發考慮…...
![](https://img-blog.csdnimg.cn/20190612225626248.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0VUX0VuZGVhdm9yaW5n,size_16,color_FFFFFF,t_70)
微信网站制作/输入搜索内容
欢迎加QQ群309798848交流C/C/linux/Qt/音视频/OpenCV 源码面前,了无秘密。阅读源码能帮助我们理解实现原理,然后更灵活的运用。 接下来我用VS2015调试Qt5.9源码。 首先提一下,Qt在WinMain中调用用户的main函数: 我们知道&#…...
![](/images/no-images.jpg)
网站建设公司十大/小红书关键词搜索量查询
一、首次适应算法(First Fit——FF) 算法思想: 每次都从低地址查找,找到第一个能满足大小的空闲分区。 如何实现: 空闲分区以地址递增的顺序排列每次分配内存时从低地址顺序查找空闲分区链(空闲分区表&…...
![](/images/no-images.jpg)
苹果电脑用什么软件做网站/网络推广网上营销
分类简介: 阅读他人的代码,可以学到很多东西,从思路,到方案,一系列都可以在项目代码中体现,所以,此分类专门用于记录阅读过的项目代码,并在上面给出自己的理解和注释 在此,感谢原作者…...
![](http://static.blog.csdn.net/images/save_snippets.png)
icp备案证书号查询/沈阳网站制作优化推广
Spring实现定时任务方法 标签: springquartztask 2017-03-11 02:02 190人阅读 评论(0) 收藏 举报 分类: spring(3) 作者同类文章Xtask quartz 版权声明:本文为博主原创文章࿰…...
![](https://img-blog.csdnimg.cn/img_convert/12a9d24d7b8e267c0a2fce3f0a59b945.png)
动态表情包在线制作网站/网络宣传的方法有哪些
相对中资公司来说,美国或者西方公司的面试流程更加复杂,考核的内容更多。 不管是那种面试,很多时候求职者会遇到:面着面着就没了。 当然我们这说的只是你应聘中层以下的技术或者部分管理岗。 如果你是应聘公司高层,…...