孤君无依

文章 评论 浏览 27

孤君无依 2025-02-20 19:51:14

一种方法是使用预处理器宏。

使用此方法,很容易添加新元素。并且,导入/导出功能将自动更新。

#ifndef NOINC
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#endif

// define all struct members
#define ALLSTRUCT(_cmd) \
    _cmd(uint16_t,"%u",model_number) \
    _cmd(uint16_t,"%u",serial_number) \
    _cmd(uint16_t,"%u",firmware_version)

// define symbol
#define SYMDEF(_typ,_fmt,_sym) \
    _typ _sym;

// define struct
typedef struct ID_Info {
    ALLSTRUCT(SYMDEF)
} ID_Info;

ID_Info id_info;

// deserialize
#define SYMIN(_typ,_fmt,_sym) \
    do { \
        str->_sym = *(_typ *) ptr; \
        ptr += sizeof(_typ); \
    } while (0);

// serialize
#define SYMOUT(_typ,_fmt,_sym) \
    do { \
        *(_typ *) ptr = str->_sym; \
        ptr += sizeof(_typ); \
    } while (0);

// print
#define SYMPRT(_typ,_fmt,_sym) \
    printf("  " #_sym "=" _fmt " (%8.8X)\n",str->_sym,str->_sym);

// struct_out -- output struct to byte array
uint8_t *
struct_out(const ID_Info *str,uint8_t *ptr)
{

    ALLSTRUCT(SYMOUT)

    return ptr;
}

// struct_in -- input struct from byte array
const uint8_t *
struct_in(ID_Info *str,const uint8_t *ptr)
{

    ALLSTRUCT(SYMIN)

    return ptr;
}

// struct_prt -- print struct to byte array
void
struct_prt(const ID_Info *str)
{

    printf("struct_prt:\n");
    ALLSTRUCT(SYMPRT)
}

// prtu8 -- print byte array
void
prtu8(const uint8_t *ptr,size_t count,const char *sym)
{

    printf("%s:",sym);

    for (size_t idx = 0;  idx < count;  ++idx)
        printf(" %2.2X",ptr[idx]);

    printf("\n");
}

int
main(void)
{

    uint8_t data_in[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
    uint8_t data_out[sizeof(data_in)];

    // show original byte array
    prtu8(data_in,sizeof(data_in),"data_in");

    // import data into struct
    struct_in(&id_info,data_in);

    // show struct values
    struct_prt(&id_info);

    // export data from struct
    struct_out(&id_info,data_out);

    // show exported byte array
    prtu8(data_out,sizeof(data_out),"data_out");

    // reimport the struct data
    struct_in(&id_info,data_out);

    // show struct data
    struct_prt(&id_info);

    return 0;
}

这是[已编辑]预处理器输出:

typedef struct ID_Info {
    uint16_t model_number;
    uint16_t serial_number;
    uint16_t firmware_version;
} ID_Info;
ID_Info id_info;
uint8_t *
struct_out(const ID_Info * str, uint8_t * ptr)
{
    do {
        *(uint16_t *) ptr = str->model_number;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        *(uint16_t *) ptr = str->serial_number;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        *(uint16_t *) ptr = str->firmware_version;
        ptr += sizeof(uint16_t);
    } while (0);
    return ptr;
}

const uint8_t *
struct_in(ID_Info * str, const uint8_t * ptr)
{
    do {
        str->model_number = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        str->serial_number = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        str->firmware_version = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    return ptr;
}

void
struct_prt(const ID_Info * str)
{
    printf("struct_prt:\n");
    printf("  " "model_number" "=" "%u" " (%8.8X)\n", str->model_number, str->model_number);
    printf("  " "serial_number" "=" "%u" " (%8.8X)\n", str->serial_number, str->serial_number);
    printf("  " "firmware_version" "=" "%u" " (%8.8X)\n", str->firmware_version, str->firmware_version);
}

void
prtu8(const uint8_t * ptr, size_t count, const char *sym)
{
    printf("%s:", sym);
    for (size_t idx = 0; idx < count; ++idx)
        printf(" %2.2X", ptr[idx]);
    printf("\n");
}

int
main(void)
{
    uint8_t data_in[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
    uint8_t data_out[sizeof(data_in)];

    prtu8(data_in, sizeof(data_in), "data_in");
    struct_in(&id_info, data_in);
    struct_prt(&id_info);
    struct_out(&id_info, data_out);
    prtu8(data_out, sizeof(data_out), "data_out");
    struct_in(&id_info, data_out);
    struct_prt(&id_info);
    return 0;
}

这是测试程序输出:

data_in: 00 11 22 33 44 55
struct_prt:
  model_number=4352 (00001100)
  serial_number=13090 (00003322)
  firmware_version=21828 (00005544)
data_out: 00 11 22 33 44 55
struct_prt:
  model_number=4352 (00001100)
  serial_number=13090 (00003322)
  firmware_version=21828 (00005544)

One way to do this is with preprocessor macros.

With this method, it is easy to add new elements. And, the import/export functions will be automatically updated.

#ifndef NOINC
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#endif

// define all struct members
#define ALLSTRUCT(_cmd) \
    _cmd(uint16_t,"%u",model_number) \
    _cmd(uint16_t,"%u",serial_number) \
    _cmd(uint16_t,"%u",firmware_version)

// define symbol
#define SYMDEF(_typ,_fmt,_sym) \
    _typ _sym;

// define struct
typedef struct ID_Info {
    ALLSTRUCT(SYMDEF)
} ID_Info;

ID_Info id_info;

// deserialize
#define SYMIN(_typ,_fmt,_sym) \
    do { \
        str->_sym = *(_typ *) ptr; \
        ptr += sizeof(_typ); \
    } while (0);

// serialize
#define SYMOUT(_typ,_fmt,_sym) \
    do { \
        *(_typ *) ptr = str->_sym; \
        ptr += sizeof(_typ); \
    } while (0);

// print
#define SYMPRT(_typ,_fmt,_sym) \
    printf("  " #_sym "=" _fmt " (%8.8X)\n",str->_sym,str->_sym);

// struct_out -- output struct to byte array
uint8_t *
struct_out(const ID_Info *str,uint8_t *ptr)
{

    ALLSTRUCT(SYMOUT)

    return ptr;
}

// struct_in -- input struct from byte array
const uint8_t *
struct_in(ID_Info *str,const uint8_t *ptr)
{

    ALLSTRUCT(SYMIN)

    return ptr;
}

// struct_prt -- print struct to byte array
void
struct_prt(const ID_Info *str)
{

    printf("struct_prt:\n");
    ALLSTRUCT(SYMPRT)
}

// prtu8 -- print byte array
void
prtu8(const uint8_t *ptr,size_t count,const char *sym)
{

    printf("%s:",sym);

    for (size_t idx = 0;  idx < count;  ++idx)
        printf(" %2.2X",ptr[idx]);

    printf("\n");
}

int
main(void)
{

    uint8_t data_in[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
    uint8_t data_out[sizeof(data_in)];

    // show original byte array
    prtu8(data_in,sizeof(data_in),"data_in");

    // import data into struct
    struct_in(&id_info,data_in);

    // show struct values
    struct_prt(&id_info);

    // export data from struct
    struct_out(&id_info,data_out);

    // show exported byte array
    prtu8(data_out,sizeof(data_out),"data_out");

    // reimport the struct data
    struct_in(&id_info,data_out);

    // show struct data
    struct_prt(&id_info);

    return 0;
}

Here is the [redacted] preprocessor output:

typedef struct ID_Info {
    uint16_t model_number;
    uint16_t serial_number;
    uint16_t firmware_version;
} ID_Info;
ID_Info id_info;
uint8_t *
struct_out(const ID_Info * str, uint8_t * ptr)
{
    do {
        *(uint16_t *) ptr = str->model_number;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        *(uint16_t *) ptr = str->serial_number;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        *(uint16_t *) ptr = str->firmware_version;
        ptr += sizeof(uint16_t);
    } while (0);
    return ptr;
}

const uint8_t *
struct_in(ID_Info * str, const uint8_t * ptr)
{
    do {
        str->model_number = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        str->serial_number = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    do {
        str->firmware_version = *(uint16_t *) ptr;
        ptr += sizeof(uint16_t);
    } while (0);
    return ptr;
}

void
struct_prt(const ID_Info * str)
{
    printf("struct_prt:\n");
    printf("  " "model_number" "=" "%u" " (%8.8X)\n", str->model_number, str->model_number);
    printf("  " "serial_number" "=" "%u" " (%8.8X)\n", str->serial_number, str->serial_number);
    printf("  " "firmware_version" "=" "%u" " (%8.8X)\n", str->firmware_version, str->firmware_version);
}

void
prtu8(const uint8_t * ptr, size_t count, const char *sym)
{
    printf("%s:", sym);
    for (size_t idx = 0; idx < count; ++idx)
        printf(" %2.2X", ptr[idx]);
    printf("\n");
}

int
main(void)
{
    uint8_t data_in[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
    uint8_t data_out[sizeof(data_in)];

    prtu8(data_in, sizeof(data_in), "data_in");
    struct_in(&id_info, data_in);
    struct_prt(&id_info);
    struct_out(&id_info, data_out);
    prtu8(data_out, sizeof(data_out), "data_out");
    struct_in(&id_info, data_out);
    struct_prt(&id_info);
    return 0;
}

Here is the test program output:

data_in: 00 11 22 33 44 55
struct_prt:
  model_number=4352 (00001100)
  serial_number=13090 (00003322)
  firmware_version=21828 (00005544)
data_out: 00 11 22 33 44 55
struct_prt:
  model_number=4352 (00001100)
  serial_number=13090 (00003322)
  firmware_version=21828 (00005544)

在C中动态填充结构

孤君无依 2025-02-20 14:56:01

问题是最初是不确定的,因为注意到了最初是一个空的数组,因此您需要检查项目是否未定义,然后通过在点之前添加问号来访问Noticeno,例如:

item?.noticeNo

the problem is that item is initially undefined because noticeDatas is an initially empty array so you need to check if item is undefined before accessing noticeNo by adding a question mark before the dot, like this:

item?.noticeNo

TypeError:无法读取未定义的属性(Reading&#x27; Noticeno&#x27;)react.js

孤君无依 2025-02-20 04:08:40

您需要使用k作为新词典的键,而不是使用+操作员:

totalErrors={}

for k in sorted(ErrorTypes):
    if (ErrorTypes[k] not in totalErrors):
        totalErrors[k] = ErrorTypes[k]

You need to use k as a key to the new dictionary, instead of using + operator:

totalErrors={}

for k in sorted(ErrorTypes):
    if (ErrorTypes[k] not in totalErrors):
        totalErrors[k] = ErrorTypes[k]

将值从地图插入另一个地图

孤君无依 2025-02-20 01:17:22

两个解决方法。一个是棘手地抓住额外的空格。

getchar(); // (1) add `getchar()`
scanf("%c", &c1);

scanf(" %c", &c1); // (2) add whitespace before %c

另一个是使用fgets()将其改为scanf()。注意:get()是不安全的,请参见为什么获得危险

,我更喜欢推荐第二种方式。因为它更可读可维护。例如,以第一个方式,您必须在添加/移动一些scanf()之前思考一段时间。

Two workarounds. One is catch the extra whitespace trickly.

getchar(); // (1) add `getchar()`
scanf("%c", &c1);

scanf(" %c", &c1); // (2) add whitespace before %c

The other is using fgets() to instead scanf(). Note: gets() is unsafe, see why gets is dangerous

By contrast, I would prefer to recommend the second way. Because it's more readable and maintainable. For example, in first way, you must think a while before adding/moving some scanf().

scanf()将newline字符留在缓冲区中

孤君无依 2025-02-19 21:34:29

这个CSS对我来说是完美的

    input::-ms-reveal,
    input::-ms-clear {
        display: none;
    }

this css works perfect for me

    input::-ms-reveal,
    input::-ms-clear {
        display: none;
    }

密码字段上的眼睛图标有时是可见的,有时看不到

孤君无依 2025-02-19 19:59:38

最短的方法是使用字典理解

a = {'a': '12 34 12','b':'23 43 12','c':'21' }
a = {key: list(map(int, val.split())) for key, val in a.items()}

输出:

{'a': [12, 34, 12], 'b': [23, 43, 12], 'c': [21]}

您可以使用split()函数将列表列在列表中。然后,使用地图将每个列表项目的整数制成整数,因为它们被存储为字符串。最后,使用围绕地图的列表,因为地图返回地图对象而不是列表。

希望这有帮助!请询问是否有什么不清楚。

The shortest way is to use dictionary comprehension:

a = {'a': '12 34 12','b':'23 43 12','c':'21' }
a = {key: list(map(int, val.split())) for key, val in a.items()}

Output:

{'a': [12, 34, 12], 'b': [23, 43, 12], 'c': [21]}

You can use the split() function to make a list out of your list. Then use map to make an integer of each of your list items, since they are stored as strings. Lastly, use list around map, since map returns a map object, not a list.

Hope this helps! Please ask if anything is unclear.

在Python中的字典列表中将每个键的值分开

孤君无依 2025-02-19 12:55:21

是的,您可以将Joy UI与材料UI一起使用,但是您必须实施解决方法,否则某些组件会引发错误,并且无法正常工作或完全工作。

siriwatknp 更新了代码,并写了指南关于如何一起使用Joy UI和材料UI。如果您不实现指南中描述的修复程序,那么当您尝试在同一项目中使用两个库时,它很可能会失败。

在此处查看如何一起使用欢乐和材料UI的指南:
https://github.com/mui/material-ui/blob/master/master/data/data/joy/guides/guides/ususe-joy-joy-ui--ui-and-material-ui/using-joy-joy-ui--ui-and-material -ui.md

:::警告警告: Joy UI与材料UI达到零件奇偶校验,我们建议您选择一个或另一个。它们不仅具有不同的设计语言(因此是不同的主题结构),而且还会增加您的捆绑尺寸,并可能产生不必要的复杂性。 :::

我相信他们会尽快在官方网站上发布本指南,但我只能在他们的GitHub仓库中找到该指南。

更新:

指南现在在其官方网站上:
https://mui.com/joy -ui/guides/using-joy-ui-ui and-material-ui-togeth/

Yes, you can use Joy UI with Material UI, but you will have to implement a workaround, otherwise some components will throw an error and not work well or work at all.

siriwatknp updated the code and wrote a guide about how to use Joy UI and Material UI together. If you dont implement the fix described in the guide, then it will most likely fail when you try to use both libraries in the same project.

See the guide on how to use Joy and Material UI together here:
https://github.com/mui/material-ui/blob/master/docs/data/joy/guides/using-joy-ui-and-material-ui/using-joy-ui-and-material-ui.md

:::warning warning Note: Once Joy UI reaches component parity with Material UI, we recommend you to choose one or the other. Not only do they have a different design language (and therefore a different theme structure) but they would increase your bundle size as well as potentially create unnecessary complexities. :::

I believe they will post this guide on the official website soon, but I can only find the guide in their Github repo.

Update:

Guide is now on their official website:
https://mui.com/joy-ui/guides/using-joy-ui-and-material-ui-together/

我可以一起使用Joy UI与材料UI一起使用吗?

孤君无依 2025-02-19 07:55:13

编辑:
您还可以使用Immerjs库在下面的样子下进行突变状态
demo demo

    const h3ClickHandler = (index) => {
      setData(
      produce((draft) => {
        draft[index] = 
         draft[index].toString().split("").reverse().join("");
      })
    );
  };

====================== ==

Orignal答案:
H3ClickHandler您正在突变状态存在问题
您可以将以下H3ClickHandler方法修改为下面,然后尝试一下:

const h3ClickHandler = (index) => {
    setData((prev) => {
      const dataVal = data[index].toString().split("").reverse().join("");
      const updateData = prev.map((p, i) => {
        if (i === index) {
          return dataVal;
        }
        return p;
      });

      console.log(updateData);
      return updateData;
    });
  };

我创建了代码沙盒示例,您可以尝试一下
https://codesandbox.io/s/vigilant-lamarr-7ou2yg?file=/src/src/app.js:309-650

EDIT:
You can also mutate state using immerjs library below how it would look like with immer js
DEMO

    const h3ClickHandler = (index) => {
      setData(
      produce((draft) => {
        draft[index] = 
         draft[index].toString().split("").reverse().join("");
      })
    );
  };

======

Orignal Answer:
There is an issue with the h3ClickHandler you are mutating the state instead you should return a new instance of the array that is to do in an immutable way
You can modify the below h3ClickHandler method to below and give it a try:

const h3ClickHandler = (index) => {
    setData((prev) => {
      const dataVal = data[index].toString().split("").reverse().join("");
      const updateData = prev.map((p, i) => {
        if (i === index) {
          return dataVal;
        }
        return p;
      });

      console.log(updateData);
      return updateData;
    });
  };

I have create the code sandbox example, which you can give it a try
https://codesandbox.io/s/vigilant-lamarr-7ou2yg?file=/src/App.js:309-650

React-页面未更新状态更改

孤君无依 2025-02-18 15:06:36

如下代码所示,您可以在本地的自定义设置中添加concurrent_requests,以启用并发请求。蜘蛛可以定义自己的设置,该设置将优先并覆盖项目。要阅读更多每个蜘蛛设置,请参阅 this


 class WebSpider(scrapy.Spider):
    name= 'webspider'

    custom_settings = {
     'CONCURRENT_REQUESTS' = 32
     }

    def __init__(self, country=None, category=None, *args, **kwargs):
        self.start_urls.append(url[country][category])

    def start_requests(self):
        for url in self.start_urls:
            request = Request(
                url=url,
                headers=self.default_headers,
                callback=self.parse, 
                cookies=self.cookies,
                cb_kwargs=dict(link= url, asin= self.asin),
            )
            yield request

您可以使用许多其他设置,或者与concurrent_requests一起使用。

concurrent_requests_per_ip - 设置每个IP地址的并发请求的数量。

concurrent_requests_per_domain - 定义每个域允许的请求数。

max_concurrent_requests_per_domain - 设置域允许的并发请求数的最大限制。

As shown in the code below, you can add CONCURRENT_REQUESTS in the custom settings for this particular spider locally to enable concurrency requests. Spiders can define their own settings that will take precedence and override the project ones.To read more Setting per Spider, refer this


 class WebSpider(scrapy.Spider):
    name= 'webspider'

    custom_settings = {
     'CONCURRENT_REQUESTS' = 32
     }

    def __init__(self, country=None, category=None, *args, **kwargs):
        self.start_urls.append(url[country][category])

    def start_requests(self):
        for url in self.start_urls:
            request = Request(
                url=url,
                headers=self.default_headers,
                callback=self.parse, 
                cookies=self.cookies,
                cb_kwargs=dict(link= url, asin= self.asin),
            )
            yield request

There are many additional settings that you can use instead of, or together with CONCURRENT_REQUESTS.

CONCURRENT_REQUESTS_PER_IP – Sets the number of concurrent requests per IP address .

CONCURRENT_REQUESTS_PER_DOMAIN – Defines the number of concurrent requests allowed for each domain.

MAX_CONCURRENT_REQUESTS_PER_DOMAIN – Sets a maximum limit on the number of concurrent requests allowed for a domain.

当只有一个启动URL时,如何实现废弃的并发性?

孤君无依 2025-02-18 11:58:04

当您进入文件夹时,那里没有config.json文件。

解决方案

  • MainFolder运行您的脚本,并传递正确的路径(foldera/config.json)。
  • 将文件夹添加到路径上,请参见
  • 在尝试阅读config.json请参见

When you are in FolderB there is no config.json file there.

Solutions

  • Run your script from MainFolder and pass correct path (FolderA/config.json).
  • Add folders to path, see.
  • Change working directory to FolderB before trying to read config.json, see.

如何在Python函数中读取文件并从其他Python文件中调用该函数?

孤君无依 2025-02-18 07:03:32

它是有效的,但乍一看不是透明的。原因是 xlog(x)的数学限制为 x-&gt; 0 是0(我们可以使用L'HOSTIVE规则证明这一点)。在这方面,该功能的最强大定义应该是,

entropy.safe <- function (p) {
  if (any(p > 1 | p < 0)) stop("probability must be between 0 and 1")
  log.p <- numeric(length(p))
  safe <- p != 0
  log.p[safe] <- log(p[safe])
  sum(-p * log.p)
}

但简单地删除p = 0案例给出了相同的结果,因为p = 0的结果是0无论如何。

entropy.brutal <- function (p) {
  if (any(p > 1 | p < 0)) stop("probability must be between 0 and 1")
  log.p <- log(p)
  ## as same as sum(na.omit(-p * log.p))
  sum(-p * log.p, na.rm = TRUE)
}

## p has a single 0
( p <- seq(0, 1, by = 0.1) )
#[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
entropy.brutal(p)
#[1] 2.455935
entropy.safe(p)
#[1] 2.455935

## half of p are zeros
p[1:5] <- 0
p
#[1] 0.0 0.0 0.0 0.0 0.0 0.5 0.6 0.7 0.8 0.9 1.0
entropy.brutal(p)
#[1] 1.176081
entropy.safe(p)
#[1] 1.176081

总之,我们可以使用entropy.brutalentropy.safe

It is valid, but not transparent at first glance. The reason is that the mathematical limit of xlog(x) as x -> 0 is 0 (we can prove this using L'Hospital Rule). In this regard, the most robust definition of the function should be

entropy.safe <- function (p) {
  if (any(p > 1 | p < 0)) stop("probability must be between 0 and 1")
  log.p <- numeric(length(p))
  safe <- p != 0
  log.p[safe] <- log(p[safe])
  sum(-p * log.p)
}

But simply dropping p = 0 cases gives identical results, because the result at p = 0 is 0 and contributes nothing to the sum anyway.

entropy.brutal <- function (p) {
  if (any(p > 1 | p < 0)) stop("probability must be between 0 and 1")
  log.p <- log(p)
  ## as same as sum(na.omit(-p * log.p))
  sum(-p * log.p, na.rm = TRUE)
}

## p has a single 0
( p <- seq(0, 1, by = 0.1) )
#[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
entropy.brutal(p)
#[1] 2.455935
entropy.safe(p)
#[1] 2.455935

## half of p are zeros
p[1:5] <- 0
p
#[1] 0.0 0.0 0.0 0.0 0.0 0.5 0.6 0.7 0.8 0.9 1.0
entropy.brutal(p)
#[1] 1.176081
entropy.safe(p)
#[1] 1.176081

In conclusion, we can use either entropy.brutal or entropy.safe.

熵计算给出了NAN-是否对NA.OMIT进行有效的调整?

孤君无依 2025-02-17 05:15:48

尝试改变

esc.freq(500) => esc.freq(250)

x=3600
print (map(3600,256,65535,10000,20000)*100)

try to change

esc.freq(500) => esc.freq(250)

x=3600
print (map(3600,256,65535,10000,20000)*100)

关于在微python中组合def函数()和pwm dut_ns()的问题

孤君无依 2025-02-17 02:19:17

虚幻4:转到窗口 - &gt;视口2。将窗口拖到某个地方,您将有2个视口:

​不更新游戏!
但是我发现了这个插件:
https://github.com/jackknobel/gameviewportsync

作为开始开发自己的插件的参考。

Unreal 4: Go to Window -> Viewport 2. Drag the window somewhere and you will have 2 viewports:

enter image description here

Press play, only one viewport will display the "gameview" and the other remains as "sceneview" - Moving stuff in the 2nd Viewport will not update the game!
But I found this plugin:
https://github.com/jackknobel/GameViewportSync

You can see if that works for you or use it as a reference to get started developing your own plugin.

如何开发UE4插件以模拟Unity 3D中的观点?

孤君无依 2025-02-16 20:55:17

您应该使用环境变量。例如,

import os

os.environ["AWS_PROFILE"] = "custom_profile"

s3fs = fs.S3FileSystem()

You should use environment variables. For example,

import os

os.environ["AWS_PROFILE"] = "custom_profile"

s3fs = fs.S3FileSystem()

将AWS配置文件与FS S3Filesystem一起使用

孤君无依 2025-02-16 18:19:08

预期类型是模型。 - &gt; deleteitem(itemDelete:model)

Easy 解决方案是传递model实例而不是三个字符串

struct Detail: View {
    
    @EnvironmentObject var model: ItemListModel
    
    let item: Model
   
    var body: some View {
        
        VStack {
                
            Text(item.name)
            Text(item.itemName)
            Button {
                model.deleteItem(itemDelete: item) 
            } label: {
                Text("Delete")
            }
            …
        }
    }
}

,而在iteg> itemlist 替换

NavigationLink(destination: Detail(name: item.name, itemName: item.itemName, itemId: item.id)) {

NavigationLink(destination: Detail(item: item)) {

The expected type is Model. -> deleteItem(itemDelete: Model)

The easy solution is to pass a Model instance rather than the three strings

struct Detail: View {
    
    @EnvironmentObject var model: ItemListModel
    
    let item: Model
   
    var body: some View {
        
        VStack {
                
            Text(item.name)
            Text(item.itemName)
            Button {
                model.deleteItem(itemDelete: item) 
            } label: {
                Text("Delete")
            }
            …
        }
    }
}

and in ItemList replace

NavigationLink(destination: Detail(name: item.name, itemName: item.itemName, itemId: item.id)) {

with

NavigationLink(destination: Detail(item: item)) {

swiftui:无法转换类型的值&#x27; string&#x27;对于预期参数类型&#x2013;好的,但是预期的论点是什么?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文