AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[arrays](coding)

Martin Hope
Md. Shiam Hossain
Asked: 2025-04-21 14:32:01 +0800 CST

我从 API 响应中获取了数组数据。我想使用 Laravel 将这些数据保存到我的数据库中。

  • 5

这是响应数据

array:3 [▼ // app\Http\Controllers\DataSend.php:38
  "status" => 200
  "message" => "Consignment has been created successfully."
  "consignment" => array:11 [▼
    "consignment_id" => 139732775
    "invoice" => "fddf51213"
    "tracking_code" => "854272742CC"
    "recipient_name" => "APi Test"
    "recipient_phone" => "01900110011"
    "recipient_address" => "address is here"
    "cod_amount" => 1
    "status" => "in_review"
    "note" => "Handle with care"
    "created_at" => "2025-04-21T05:53:11.000000Z"
    "updated_at" => "2025-04-21T05:53:11.000000Z"
  ]
]

我想将这些数据插入到我的数据库中。

$responses变量中的所有数据

foreach ($responses as $response) {
    $curDatains = new CurrierData();
    $curDatains->orderId = 1;
    $curDatains->orderInvoice = $response->invoice;
    $curDatains->consignment_id = $response->consignment_id;
    $curDatains->tracking_code = $response->tracking_code;
    $curDatains->status = $response->status;
    $curDatains->save();
}

在我的代码中我遇到了错误

尝试读取 int 上的属性“invoice”

arrays
  • 1 个回答
  • 46 Views
Martin Hope
Kanwar
Asked: 2025-04-20 09:42:22 +0800 CST

尝试理解 C 语言结构体中的数组初始化

  • 6

我正在尝试初始化在 C 结构中声明的数组。

目标是使用一个数组并将其作为参数传递给一个函数,然后该函数复制传递的数组的每个元素并将其分配给结构内的数组。

#include <stdio.h>


typedef struct {
    int v;
    int arrayInStruct[];
} TEST;

void ProblemCode1(){
    TEST test1; //Array Declared after struct declaration.
    int array[5] = {1,2,3,4,5};
    for(int i = 0; i < 5; i++){
        test1.arrayInStruct[i] = array[i];
        printf("%d", test1.arrayInStruct[i]);
    }
    return;
}

void ProblemCode2(int a[]){
    //Array Pass by Value and elements assigned to struct array.
    TEST test2;
    test2.arrayInStruct[5] = 0;
    for(int i = 0; i < 5; i++){
        test2.arrayInStruct[i] = a[i];
        printf("%d", test2.arrayInStruct[i]);
    }
    return;
}


void ProblemCode3(int a[]){
    //Array Pass by Value and elements assigned to struct array 
    //and struct array initilzation missing as compared to ProblemCode2.
    TEST test2;
    for(int i = 0; i < 5; i++){
        test2.arrayInStruct[i] = a[i];
        printf("%d", test2.arrayInStruct[i]);
    }
    return;
}

void WorkingCode1(){
    int array[5] = {1,2,3,4,5};
    TEST test1; //Array Created Before Declaration of Struct and not passed via function.
    for(int i = 0; i < 5; i++){
        test1.arrayInStruct[i] = array[i];
        printf("%d", test1.arrayInStruct[i]);
    }
    printf("\n");
    return;
}

void WorkingCode2(){
    int array1[5] = {1,2,3,4,5};
    int array2[5] = {0};
    for(int i = 0; i < 5; i++){
        array2[i] = array1[i];
        printf("%d", array2[i]);
    }
    printf("\n");
    return;
}

int main(){
    //int passbyValue[] = {1,2,3,4,5};
    //ProblemCode1();
    //ProblemCode2(passbyValue);
    //ProblemCode3(passbyValue);
    WorkingCode1();
    WorkingCode2();
    return 0;
}

有人可以解释一下为什么某些功能有效而其他功能无效吗?

arrays
  • 1 个回答
  • 103 Views
Martin Hope
Serdar Didan
Asked: 2025-04-16 07:35:01 +0800 CST

Rust 结构中使用数组代替向量

  • 6

我用多种编程语言编写了一些实现相同功能的小程序。我比较了它们的性能和内存占用。这是我编写的测试程序之一。

两个程序读取同一个文件。该文件包含由 \t(制表符)和 \n(回车符)连接的数据。内容类似如下。

aaaa\tbbb\tccc\tddd\teee\tfff\tggg\thhh\n
aaaa\tbbb\tccc\tddd\teee\tfff\tggg\thhh\n
aaaa\tbbb\tccc\tddd\teee\tfff\tggg\thhh\n
aaaa\tbbb\tccc\tddd\teee\tfff\tggg\thhh

我创建的文件有 14 列和 63 行。这些数字可能会更改。这并不重要,因为我正在测试它。

我使用 split('\n') 获取行。然后使用 split('\t') 获取行中的字段。这是一个非常简单的反序列化过程。程序读取文件一次,然后对其进行 200,000 次反序列化。然后将时间打印到控制台。

去:

package main

import (
    "fmt"
    "os"
    "strings"
    "time"
)

type Datatable struct {
    id   int
    rows [][]string
}

func main() {
    start := time.Now()

    dat, err := os.ReadFile("C:\\Temp\\test1.txt")
    if err != nil {
        panic("file not found")
    }
    str := string(dat)

    count := 200_000
    tables := make([]Datatable, count)

    for i := 0; i < count; i++ {
        table := Datatable{i, nil}
        var lines []string = strings.Split(str, "\n")
        table.rows = make([][]string, len(lines))
        for j, l := range lines {
            table.rows[j] = strings.Split(l, "\t")
        }
        tables[i] = table
    }

    end := time.Now()
    elapsed := end.Sub(start)
    fmt.Println("Time: ", elapsed)

    var b []byte = make([]byte, 1)
    os.Stdin.Read(b)
}

锈:

use std::fs;
use std::time::SystemTime;
use std::io::{self, BufRead};

struct Table<'a>{
    id: usize,
    rows: Vec<Vec<&'a str>>,
}
fn main() {
    let start = SystemTime::now();
    let str = fs::read_to_string("C:\\Temp\\test1.txt")
        .expect("read_to_string: failed");

    let count = 200_000;
    let mut tables = Vec::with_capacity(count);
    for i in 0..count {
        let lines = str.split('\n');
        let mut table = Table {
            id : i,
            rows : Vec::with_capacity(lines.size_hint().0),
        };
        for item in lines {
            table.rows.push(item.split('\t').collect::<Vec<&str>>());
        }
        tables.push(table);
    }
    println!("Time: {}", start.elapsed().expect("elapsed: failed").as_millis());

    let mut line = String::new();
    let stdin = io::stdin();
    stdin.lock().read_line(&mut line).expect("read_line: failed");
}
  • go版本go1.24.2 windows/amd64
  • rustc 1.85.1 (4eb161250 2025-03-15)
  • 操作系统:Windows 11

构建命令:

go build -ldflags "-s -w"
cargo build --release

在我的电脑上结果如下:

去:

Time     : 4510 milis
RAM usage: 3217 MB

锈

Time     : 5845 milis
RAM usage: 3578 MB

我尽量把代码写得简单一点,大家可以直接复制粘贴试试。

Rust 代码可以运行。但它比 Go 慢,而且占用更多内存。在编写代码之前,我希望 Rust 能跑得更快。也许有什么我不知道的地方。

在 Rust 的结构体中使用数组可能会使其运行得更快。但我不确定这是否可行。我想知道的是,如何用 Rust 编写这段代码才能使其运行得更快?

arrays
  • 3 个回答
  • 159 Views
Martin Hope
Márton Horváth
Asked: 2025-04-15 23:41:15 +0800 CST

为什么手动将拟合曲线分成两部分时无法获得连续的曲线?

  • 5

我的目标是使以下函数适合我的数据:

def P(t, CP, Pan, tau):
    P_val = CP + Pan / (1 + t / tau)
    P_val = np.where(t >= 900, P_val - 0.8 * np.log(t / 900), P_val)
    return P_val

然后绘制此函数。但是,我想对t<900和 的情况使用两种不同的颜色t>=900。因此,我决定分别绘制曲线的两部分,如下所示。然而,即使我尝试明确地将 合并到用于绘制曲线两部分的时间数组中 ,这仍然会导致两条曲线之间留有很小的空隙。有点像这样:t=900

如果强制包含t=900,间隙问题可以解决,但其余问题就会崩溃,我得到两条绘制的曲线: 在此处输入图片描述

我应该如何解决这个问题?或者是否有其他解决方法/方法(例如,多色线条)可以得到具有两种不同颜色的连续曲线,我可以在这里使用吗?根据Matplotlib 文档,LineCollection可能有用,但不幸的是,我不太习惯matplotlib.collections。

这是我的完整代码:

import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt

# Data
t2 = np.array([
    80,
    160,
    200,
    320,
    400,
    640,
    800,
    900,
    1000,
    1280,
    2000,
])

P_t2 = np.array([
    4.64,
    3.97,
    3.79,
    3.48,
    3.36,
    3.18,
    3.11,
    3.08,
    3.06,
    3.01,
    2.94,
])

t_min = 0 
t_cutoff = 7500  

mask = (t2 >= t_min) & (t2 <= t_cutoff)

t_filtered = t2[mask]
P_t_filtered = P_t2[mask]

def P(t, CP, Pan, tau):
    P_val = CP + Pan / (1 + t / tau)
    P_val = np.where(t >= 900, P_val - 0.8 * np.log(t / 900), P_val)
    return P_val

initial_guesses = [3.0, 4.0, 50.0]
bounds = ([1.35, 0, 0], [np.inf, np.inf, np.inf])

popt2, pcov2 = curve_fit(P, t_filtered, P_t_filtered, p0=initial_guesses, bounds=bounds, maxfev=5000)


t_fit2 = np.linspace(1, max(t2), 500)
P_fit2 = P(t_fit2, *popt2)


t_fit2_middle = t_fit2[(t_fit2 >= 80) & (t_fit2 <= 900)]
t_fit2_middle = np.append(t_fit2_middle, 900)               # include 900 explicitly

t_fit2_over = t_fit2[t_fit2 >= 900]
#t_fit2_over = np.append(t_fit2_over, 900)               # include 900 explicitly

P_fit2_middle = P(t_fit2_middle, *popt2)
P_fit2_over1 = P(t_fit2_over, *popt2)

#plotting
plt.plot(t_fit2_middle, P_fit2_middle, color='green', linewidth=2)
plt.plot(t_fit2_over, P_fit2_over1, color='red', linewidth=2)

plt.fill_between(t_fit2_middle, 0, P_fit2_middle, color='green', alpha=0.3, hatch='//')
plt.fill_between(t_fit2_over, P_fit2_over1, color='red', alpha=0.3, hatch='//')

plt.xlim(1, 1250)
plt.ylim(0, 8)
plt.minorticks_on()

ax = plt.gca()
ax.tick_params(labelbottom=False, labelleft=False)

plt.tight_layout()
plt.show()
arrays
  • 1 个回答
  • 22 Views
Martin Hope
clearcut3000
Asked: 2025-04-15 14:59:45 +0800 CST

查找特定连续子串的数量的算法

  • 7

我正在尝试解决以下算法问题:

每天,鲍勃都会去上班,并完成 26 项可能的任务之一。这些任务用英文字母从 a 到 z 编码。有时鲍勃会执行老板分配的任务,有时他可以选择自己完成这 26 项可能的任务中的哪一项。这样的日子用符号 标记!。老板已经为鲍勃制定了未来 N 天的工作计划。鲍勃非常不喜欢连续几天做同样的任务,为了向老板表明他有多无聊,他决定计算有多少种方法可以选择一个至少两天的连续时间段,在此期间他每天都执行相同的任务。

也就是说,Bob 考虑从 L 天到 R 天的所有可能的时间段,其中 L < R,并且如果他选择自己的工作时,该时间段内所有日子的任务都是相同的,那么他认为该时间段很无聊。

趁Bob无聊的时候,帮他确定接下来N天的工作计划中无聊的段数。

输入格式

输入一行,由大写英文字母和符号!组成的字符序列——未来N(1≤N≤1000000)天的工作计划。

输出格式

输出一个数字——计划中的钻孔段数。

示例 1

输入:a!b!c

输出:5

示例 2

输入:a!

输出:1

笔记

第一个例子中所有可能的段都在|和之间|

|a!|b!c
a|!b|!c
a|!b!|c
a!|b!|c
a!b|!c|

我将任务正式化如下:

问题

给定一个 N 天的工作计划,以大写英文字母('a' 到 'z')和感叹号('!')组成的字符串形式,计算至少两天的连续片段的数量(即从 L 天到 R 天,其中 1≤L<R≤N),使得 Bob 可以在该片段内的每一天执行相同的任务。如果满足以下任一条件,则认为该片段“无聊”:

  • 该段内的所有字符都是相同的非“!”字符。

  • 该片段至少包含一个感叹号(“!”)。

输入

表示 N 天工作计划的单个字符串。

该字符串仅包含大写英文字母(“a”到“z”)和感叹号(“!”)。

字符串 N 的长度介于 1 到 1,000,000 之间(包括 1 和 1,000,000)(1≤N≤10 6)。

输出

一个整数,表示给定工作计划中“无聊”段的总数。

我的代码

func solve() {
  guard let plan = readLine() else { return }
  let n = plan.count
  let planArray = Array(plan)
  var boringSegmentCount = 0
  for i in 0..<n {
    var nonWildcards = Set<Character>()
    for j in i..<n {
      if planArray[j] != "!" {
        nonWildcards.insert(planArray[j])
      }
      if j > i && nonWildcards.count <= 1 {
        boringSegmentCount += 1
      }
    }
  }
  print(boringSegmentCount)
  
}

提供的 Swift 代码旨在通过遍历输入字符串的所有可能的连续段来解决问题plan。

它使用嵌套循环来遍历字符串所有可能的连续段:

  • 外层循环(i)确定段的起始索引。
  • 内层循环(j)确定段的结束索引。

对于每个段(从索引i到j):

  • 它创建了一个Set用来nonWildcards存储非“!”的唯一字符的调用。
  • 它遍历当前段内的字符。
  • 如果字符不是“!”,则会将其添加到nonWildcards集合中。
  • 它检查段的长度是否大于 1 ( j > i) 以及段中唯一非通配符的数量是否最多为 1 ( nonWildcards.count <= 1)。
  • 如果两个条件都为真,则它会增加boringSegmentCount。

该算法的主要问题是其二次时间复杂度 O(n²),因此对于较大的值n(如问题中所述,最高为 1,000,000),该算法可能非常慢并导致超出时间限制的错误。

我的问题

有没有可能针对这个任务提出一个渐近性更低的算法?我想这个问题可以在线性时间内解决,但遗憾的是,我仍然想不出合适的逻辑。

arrays
  • 1 个回答
  • 107 Views
Martin Hope
ALICEZzz
Asked: 2025-04-11 13:13:51 +0800 CST

我们如何使用这个短语“T 的派生声明器类型列表数组”来调用这个“int * name[4]”

  • 8

在C17中我们有这个(6.7.6.2 #3):

如果在声明“ T D1”中,D1有以下形式之一:

 D [ 类型限定符列表opt 赋值表达式opt ]
 D [ 类型限定符列表opt 赋值表达式 ]
 D [ 类型限定符列表 static 赋值表达式 ]
 D [ 类型限定符列表opt ]

并且声明“ ”中为ident指定的类型T D为“派生声明器类型列表 T ”,那么为ident指定的类型 为“ T的派生声明器类型列表数组”。144 ) (有关可选类型限定符和关键字 的含义,请参见 6.7.6.3 。)static

它不是派生的float,或int,或char,它是“数组”,或“指向”。

例如,我们有int name [2][3],这里T是int,并且D1是A[2][3],形式为D[3]其中D是A[2],所以T D是int A[2],或“2个int型数组”。那么的声明类型A为“2个int型数组,3个int型数组”。

但是怎么样int * name[4]?

这里,“派生声明器类型列表 T ”将是int * name。而且,事实证明,“派生声明器类型列表T数组”将是一个指向 4 个元素的数组的指针?

最终,这是错误的,因为int *name[4]它是一个包含4个指针的数组。请解释一下。

arrays
  • 2 个回答
  • 130 Views
Martin Hope
DaccoTheTaco
Asked: 2025-04-10 17:31:55 +0800 CST

过滤 10k 个对象很慢,但是当我返回数组的副本时,速度很快,这是为什么呢?

  • 9

我在使用 Ngrx Store 和 Angular 时发现了一个奇怪的现象。基本上,我的任务目标如下例所示,其中 Person[] 中有大约 10k 个条目:

我的目标是显示特定姓氏的特定人物。这是我想到的第一个修订版本,运行速度非常慢:

export const selectPerson = createSelector(
  selectCitizensState,
  (citizensState: CitizensState): Person[] => citizensState.people ?? []
);
export const selectPeopleWithSurname = createSelector(
  selectPerson,
  selectSelectedSurnames,
  (people: Person[], surnames: string[]) => {
    if (surnames.length === 0) {
      return people;
    }
    return people.filter((person) => surnames.includes(person.surname));
  }
);

我偶然想到了这个,它比上面的代码快得多:

export const selectPerson = createSelector(
  selectCitizensState,
  (citizensState: CitizensState): Person[] => [...(citizensState.people ?? [])]
);

为什么会这样?我只是创建了 store 属性的浅拷贝。我猜想这可能和 Ngrx 的变更检测之类的机制有关,但我不太确定。

arrays
  • 1 个回答
  • 82 Views
Martin Hope
unnecessary_bootstrapping
Asked: 2025-04-08 03:54:12 +0800 CST

在 C 语言中将指针作为双指针的参数传递是否可以接受?

  • 6

因此,我一直在用 C 语言做一些学习项目,并且开始对指针更加熟悉,但是我遇到了一些似乎找不到太多信息的现象。

基本上,我创建了一个数组,为了简单起见,我从一个整数数组开始:

int x[2] = {1, 3};

现在,如果我想修改这个数组的内容,我发现我可以创建一个函数,该函数以整数指针作为参数,并x作为参数传递,并x通过指定索引来取消引用。

#include <stdio.h>

void foo(int* input){
    input[0] = 2;
    input[1] = 4;
}

int main(){
    int x[2] = {1, 3};
    printf("x[0] before: %d\nx[1] before: %d\n", x[0], x[1]);
    foo(x);
    printf("x[0] after: %d\nx[1] after: %d\n", x[0], x[1]);
}

输出

x[0] before: 1
x[1] before: 3
x[0] after: 2
x[1] after: 4

这很有趣,但我并不经常看到这种做法,所以我不确定它是否可以接受。

现在,对于更大的问题,出于某种原因,每当我想通过指定新值和指针,然后将参数设置为该新指针来更改指针本身指向的地址时,它似乎只有在我执行以下操作时才有效:

#include <stdio.h>
#include <stdlib.h>

void foo(int** input){
    int x[3] = {2, 4};
    int** ptr = x;
    *input = *ptr;
}

int main(){

    int x[2];
    x[0] = 1;
    x[1] = 3;
    printf("x[0] before: %d\n", x[0]);
    printf("x[1] before: %d\n", x[1]);
    foo(x);
    printf("x[0] after: %d\n", x[0]);
    printf("x[1] after: %d\n", x[1]);

    return 0;
}

输出:

x[0] before: 1
x[1] before: 3
x[0] after: 2
x[1] after: 4

因此,我有几个问题似乎找不到答案,可能是因为我缺乏技术词汇:

1:每当我传递带有或不带有引用的数组作为参数时,为什么参数表现为指针数组,而没有初始化指针数组并将其设置为数组的地址?这样做会有什么意想不到的后果吗?

2:如果参数是一个指针,而不是指向指针的指针,那么将指针作为参数传递给像我一样接受双指针作为参数的函数是否可以接受,这样做是否存在我应该知道的未定义行为?

3:为什么这会起作用?

arrays
  • 2 个回答
  • 101 Views
Martin Hope
Pavel Chersky
Asked: 2025-04-07 23:08:12 +0800 CST

使用“一次分配”实现二维切片的效率如何?

  • 7

我正在学习 Go,现在开始研究数组和切片。我参考了《Effective Go》和《A Tour of Go》。我对切片容量的计算公式有些疑问。请参阅下面代码中的注释。

package main

import "fmt"

func main() {

    // let's say I need to implement 5x5 picture with 2D slice
    // and I have two ways to do that in acc. with
    // https://go.dev/doc/effective_go#two_dimensional_slices

    // that said:
    // 1. six slices - six underlying arrays
    picture := make([][]uint8, 5)
    for i := range picture {
        picture[i] = make([]uint8, 5)
    }

    // 2. six slices - two* underlying arrays
    // *I THOUGHT the efficiency is hiding in number of arrays
    picture = make([][]uint8, 5)
    pixels := make([]uint8, 25)
    for i := range picture {
        // every iteration pixels[5:] allocates new array...
        picture[i], pixels = pixels[:5], pixels[5:]
        // ...but in the new iteration it's deleted
        // leaving slice of initial pixels array in picture[i]...
    }
    // ...and here we have only two arrays...
    // ...         ^^^ B5t ^^^

    // there are six arrays anyway
    // but their capacity is 5 for picture and
    // 25, 20...5 respectively for its contents
    fmt.Print(cap(picture), " ")
    for i := range picture {
        fmt.Print(cap(picture[i]), " ")
    }
    fmt.Println()
    // if you don't understand let me explain my position
    // capacity is characteristic of underlying array rather than
    // of slice itself

    // in acc. with https://go.dev/tour/moretypes/11
    // "The capacity of a slice is the number of
    // elements in the underlying array..."

    // I believe that capacity of array is immutable one and
    // one array cannot have different cap's at the same time

    picture = make([][]uint8, 5)
    for i := range picture {
        picture[i] = make([]uint8, 5)
    }

    // here we have six arrays but capacity of each is 5
    // so the first solution works efficiently than second one
    //                  I believe
    fmt.Print(cap(picture), " ")
    for i := range picture {
        fmt.Print(cap(picture[i]), " ")
    }
    fmt.Println()

}

该代码的输出是:

5 25 20 15 10 5 
5 5 5 5 5 5 

有人可以解释一下使用一种分配方法的效率隐藏在哪里吗?

arrays
  • 1 个回答
  • 94 Views
Martin Hope
Rami Aboulissane
Asked: 2025-04-07 18:14:00 +0800 CST

在 Powershell 中将结果数组中的两个属性值从字节转换为字符串

  • 5

我看到很多关于将字节数组转换为字符串的问题和答案,但我的情况却截然不同,我无法找到一种方法来做我需要的事情。

我从某个 API 生成一个结果集并将其拉入变量 $jobandtasklist 中

然后我选择我想要的属性并将其导出到 csv 文件

$jobandtasklist | select Group, Name, Active, Taskname, ExitCodeResult, DatelastExecution, Description, TaskStdOutput, TaskErrOutput | Export-Csv c:\temp\ErrorReport.csv

然后我导入上述 csv 文件

$csvresults = Import-Csv -Path 'C:\temp\ErrorReport.csv' 

TaskStdOutput 和 TaskErrOutput 的值如下所示

69 120 99 101 112 116 105 111 110 32 105 110 32 84 97 115 107 58 32 78 111 32 102 105 108 101 40 115 41 32 102 111 117 110 100

我希望将这些字节值转换为等效的字符串(我希望输出基本上对人眼来说是可读的)

我尝试下面

foreach ($result in $csvresults) {
    If ($result.TaskStdOutput -gt 1 ) {
        $result.TaskstdOutput = [System.Text.Encoding]::UTF8.GetString($result.TaskStdOutput)

        }

        else {
        
        if ($result.TaskErroutput -gt 1) {

        $result.TaskErrOutput = [System.Text.Encoding]::UTF8.GetString($result.TaskErrOutput)
    } } }

但它会引发以下错误

无法转换参数“bytes”,其值为:“92 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 46 120 109 108 32 62 32 92 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 50 48 49 55 48 54 48 57 49 54 49 55 46 120 109 108",将“GetString”转换为类型“System.Byte[]”:“无法将值“92 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 46 120 109 108 32 62 32 92 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 50 48 49 55 48 54 48 57 49 54 49 55 46 120 109 108" 转换为类型“System.Byte[]”。错误:“无法将值“92 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 46 120 109 108 32 62 32 92” 92 80 65 82 70 79 82 65 80 48 48 50 92 97 112 120 36 92 120 109 108 92 114 101 113 117 101 115 116 50 48 49 55 48 54 48 57 49 54 49 55 46 120 109 108" 输入“System.Byte”。错误:“输入字符串格式不正确。”

我在这里做错了什么?

例如使用[System.Text.Encoding]::UTF8.GetString($jobandtasklist.TaskErrOutput) 将按照我的需要将所有字节值作为字符串返回,但这对我来说毫无用处,因为我需要根据结果转换这些值才能使它们具有任何意义(例如与特定作业相关联),而不是将所有组合的 TaskStdOutput 和 TaskErrOutput 放在一个巨大的 blob 中。

arrays
  • 1 个回答
  • 41 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve