怪我太投入

文章 评论 浏览 31

怪我太投入 2025-02-15 10:30:29
l1 = ['a', 'ab','c','abc']
l1_res = []
for word in l1:
    tmp = []
    for other in l1:
        tmp.append( word in other and other != word)  # word in other != word
    if not any(tmp):
        l1_res.append(word)
print(l1_res)
l1 = ['a', 'ab','c','abc']
l1_res = []
for word in l1:
    tmp = []
    for other in l1:
        tmp.append( word in other and other != word)  # word in other != word
    if not any(tmp):
        l1_res.append(word)
print(l1_res)

如何分解此列表理解或其他单词,如何合并列表中的子集?

怪我太投入 2025-02-15 08:44:21

如果您使用的是JPA,则需要在持久性上下文中标记删除实体(例如,数据库中不在数据库中)。请记住,JPA存储库遵循ORM范式,并且没有直接在记录上行动。

任何种族条件都将在持久性上下文级别上处理。

如果您使用@transactional ,那么您将是安全的。

Also if you don't want the explicit error thrown by

If you are using JPA, you need the entity to be marked for deletion in the persistence context (e.g. not in the Database). Keep in mind JPA Repository follows the ORM paradigm and is not acting on the record directly.

Any race conditions will be handled on the persistence context level.

If you use @Transactional and you will be safe.

Also if you don't want the explicit error thrown by deleteById, when the ID is not known to the EntityManager, consider using delete (which will just return with no exception being thrown in case the ID is unknown).

春季jparepository仅在存在ID时才执行删除并避免种族条件

怪我太投入 2025-02-15 08:18:28

这是一种组合两个对象的方法。如果 optin 中的任何属性已经存在,则将其更改为 addcarddata 的数组,然后将新值推到它上:

const optIn={a:123,b:456,cardId:789,cardName:"Harry"},cardId=222,cardName="Sally";

const addCardData = {...optIn};
Object.entries({cardId,cardName}).forEach(([k,v])=>{
 (addCardData[k]=Array.isArray(addCardData[k])?addCardData[k]:[addCardData[k]]).push(v)
});

console.log(addCardData);

Here is a way to combine both objects. If any of the properties already exists in optIn it will be changed into an array in addCardData and the new value will then be pushed onto it:

const optIn={a:123,b:456,cardId:789,cardName:"Harry"},cardId=222,cardName="Sally";

const addCardData = {...optIn};
Object.entries({cardId,cardName}).forEach(([k,v])=>{
 (addCardData[k]=Array.isArray(addCardData[k])?addCardData[k]:[addCardData[k]]).push(v)
});

console.log(addCardData);

如何将数据添加到对象

怪我太投入 2025-02-15 05:03:31

这篇文章旨在为读者提供与大熊猫的合并,如何使用它以及不使用它的介绍。

特别是,这是本文将要经历的内容:

  • 基础知识 - 连接的类型(左,右,外,内)

    • 与不同的列名合并
    • 与多列合并
    • 避免在输出中重复合并键列

(以及我在此线程上的其他帖子)将无法通过:

  • performand - 相关的讨论和时间(目前)。在适当的情况下,通常值得注意的是更好的替代方案。
  • 处理后缀,删除额外的列,重命名输出和其他特定用例。还有其他(阅读:更好的)帖子可以解决这个问题,因此请弄清楚!

注意
除非另有说明,否则大多数示例默认为内连接操作,同时演示各种功能。

此外,可以复制和复制所有数据框架
您可以和他们一起玩。另外,请参见
帖子

关于如何从剪贴板读取数据框。

最后,使用Google图纸手绘加入操作的所有视觉表示。灵感来自在这里。。



足够的谈话 - 只需告诉我如何使用 Merge

设置& 基础知识的

np.random.seed(0)
left = pd.DataFrame({'key': ['A', 'B', 'C', 'D'], 'value': np.random.randn(4)})
right = pd.DataFrame({'key': ['B', 'D', 'E', 'F'], 'value': np.random.randn(4)})

left

  key     value
0   A  1.764052
1   B  0.400157
2   C  0.978738
3   D  2.240893

right

  key     value
0   B  1.867558
1   D -0.977278
2   E  0.950088
3   F -0.151357

为了简单起见,

键列具有相同的名称(目前)。 内联机

注意
这与即将到来的数字一起遵循此惯例:

  • 蓝色指示合并结果中存在的行
  • 红色指示从结果中排除的行(即删除)
  • 绿色指示结果
  • 中被 nan s替换的缺失值

为执行内在加入,呼叫

left.merge(right, on='key')
# Or, if you want to be explicit
# left.merge(right, on='key', how='inner')

  key   value_x   value_y
0   B  0.400157  1.867558
1   D  2.240893 -0.977278

这仅返回共享一个共同密钥的行(在本示例中,“ b”和“ d)。a

左外' >,

如果您指定,则可以通过指定来指定

left.merge(right, on='key', how='left')

  key   value_x   value_y
0   A  1.764052       NaN
1   B  0.400157  1.867558
2   C  0.978738       NaN
3   D  2.240893 -0.977278

nans的位置。 ,然后仅使用左右的键,而右边的数据被NAN替换为

右外的JOIN ,或者替换 JOIN是

...。

left.merge(right, on='key', how='right')

  key   value_x   value_y
0   B  0.400157  1.867558
1   D  2.240893 -0.977278
2   E       NaN  0.950088
3   F       NaN -0.151357

了数据。右 取代

NAN

>由

left.merge(right, on='key', how='outer')

  key   value_x   value_y
0   A  1.764052       NaN
1   B  0.400157  1.867558
2   C  0.978738       NaN
3   D  2.240893 -0.977278
4   E       NaN  0.950088
5   F       NaN -0.151357

。 。

中缺少行

两者 。


​>左排除加入和右排除在两个步骤中加入

对于左排出的联接,

以左外的连接的执行,然后过滤为 仅(不包括右边的所有内容),

(left.merge(right, on='key', how='left', indicator=True)
     .query('_merge == "left_only"')
     .drop('_merge', axis=1))

  key   value_x  value_y
0   A  1.764052      NaN
2   C  0.978738      NaN

在其中,在其中,

left.merge(right, on='key', how='left', indicator=True)

  key   value_x   value_y     _merge
0   A  1.764052       NaN  left_only
1   B  0.400157  1.867558       both
2   C  0.978738       NaN  left_only
3   D  2.240893 -0.977278       both

以及类似地,对于右式排除JOIN, 最后,

(left.merge(right, on='key', how='right', indicator=True)
     .query('_merge == "right_only"')
     .drop('_merge', axis=1))

  key  value_x   value_y
2   E      NaN  0.950088
3   F      NaN -0.151357

如果您需要进行合并,该合并仅保留左右的钥匙,而不是两者(IOW,执行 Anti-Join ),

则可以以类似的方式进行此操作 -

(left.merge(right, on='key', how='outer', indicator=True)
     .query('_merge != "both"')
     .drop('_merge', axis=1))

  key   value_x   value_y
0   A  1.764052       NaN
2   C  0.978738       NaN
4   E       NaN  0.950088
5   F       NaN -0.151357

<强>键列的不同名称

如果键列的命名不同 - 例如,具有 keyleft ,而 right has 键入而不是 - 然后您必须指定 left_on right_on 作为参数,而不是 on

left2 = left.rename({'key':'keyLeft'}, axis=1)
right2 = right.rename({'key':'keyRight'}, axis=1)

left2

  keyLeft     value
0       A  1.764052
1       B  0.400157
2       C  0.978738
3       D  2.240893

right2

  keyRight     value
0        B  1.867558
1        D -0.977278
2        E  0.950088
3        F -0.151357
left2.merge(right2, left_on='keyLeft', right_on='keyRight', how='inner')

  keyLeft   value_x keyRight   value_y
0       B  0.400157        B  1.867558
1       D  2.240893        D -0.977278

重复键列

避免在 keyleft 中合并 keyright 中的 >右,如果您仅想要 keyleft 键>键入(但不是两个),则可以首先将索引设置为初步步。

left3 = left2.set_index('keyLeft')
left3.merge(right2, left_index=True, right_on='keyRight')

    value_x keyRight   value_y
0  0.400157        B  1.867558
1  2.240893        D -0.977278

将其与命令的输出进行对比(即 lewd.cresge的输出(right2,left_on ='keyleft',right_on ='keyright',how ='innear'')),您会注意到 keyleft 缺少。您可以根据将哪个框架的索引设置为键来确定要保留的列。当执行一些外部联接操作时,这可能很重要。


仅从 dataframes之一 中合并一个

right3 = right.assign(newcol=np.arange(len(right)))
right3
  key     value  newcol
0   B  1.867558       0
1   D -0.977278       1
2   E  0.950088       2
3   F -0.151357       3

仅在合并之前的子集列:

left.merge(right3[['key', 'newcol']], on='key')

  key     value  newcol
0   B  0.400157       0
1   D  2.240893       1

如果您要执行左外连接,则更性能的解决方案将涉及 map

# left['newcol'] = left['key'].map(right3.set_index('key')['newcol']))
left.assign(newcol=left['key'].map(right3.set_index('key')['newcol']))

  key     value  newcol
0   A  1.764052     NaN
1   B  0.400157     0.0
2   C  0.978738     NaN
3   D  2.240893     1.0

如前所述,这与

left.merge(right3[['key', 'newcol']], on='key', how='left')

  key     value  newcol
0   A  1.764052     NaN
1   B  0.400157     0.0
2   C  0.978738     NaN
3   D  2.240893     1.0

在多个列上合并< /strong>

要在多个列上加入,请在上指定列表(或 left_on 和 right_on ,请及时及时)。

left.merge(right, on=['key1', 'key2'] ...)

或者,如果名称不同,

left.merge(right, left_on=['lkey1', 'lkey2'], right_on=['rkey1', 'rkey2'])

其他有用的合并*操作和函数

本节仅涵盖了基本知识,旨在仅促进您的食欲。有关更多示例和案例,请参见 on merge 加入 concat 以及指向功能规范的链接。



继续阅读

跳转跳到熊猫中的其他主题,以继续学习:继续学习:

*您在这里。

This post aims to give readers a primer on SQL-flavored merging with Pandas, how to use it, and when not to use it.

In particular, here's what this post will go through:

  • The basics - types of joins (LEFT, RIGHT, OUTER, INNER)

    • merging with different column names
    • merging with multiple columns
    • avoiding duplicate merge key column in output

What this post (and other posts by me on this thread) will not go through:

  • Performance-related discussions and timings (for now). Mostly notable mentions of better alternatives, wherever appropriate.
  • Handling suffixes, removing extra columns, renaming outputs, and other specific use cases. There are other (read: better) posts that deal with that, so figure it out!

Note
Most examples default to INNER JOIN operations while demonstrating various features, unless otherwise specified.

Furthermore, all the DataFrames here can be copied and replicated so
you can play with them. Also, see this
post

on how to read DataFrames from your clipboard.

Lastly, all visual representation of JOIN operations have been hand-drawn using Google Drawings. Inspiration from here.



Enough talk - just show me how to use merge!

Setup & Basics

np.random.seed(0)
left = pd.DataFrame({'key': ['A', 'B', 'C', 'D'], 'value': np.random.randn(4)})
right = pd.DataFrame({'key': ['B', 'D', 'E', 'F'], 'value': np.random.randn(4)})

left

  key     value
0   A  1.764052
1   B  0.400157
2   C  0.978738
3   D  2.240893

right

  key     value
0   B  1.867558
1   D -0.977278
2   E  0.950088
3   F -0.151357

For the sake of simplicity, the key column has the same name (for now).

An INNER JOIN is represented by

Note
This, along with the forthcoming figures all follow this convention:

  • blue indicates rows that are present in the merge result
  • red indicates rows that are excluded from the result (i.e., removed)
  • green indicates missing values that are replaced with NaNs in the result

To perform an INNER JOIN, call merge on the left DataFrame, specifying the right DataFrame and the join key (at the very least) as arguments.

left.merge(right, on='key')
# Or, if you want to be explicit
# left.merge(right, on='key', how='inner')

  key   value_x   value_y
0   B  0.400157  1.867558
1   D  2.240893 -0.977278

This returns only rows from left and right which share a common key (in this example, "B" and "D).

A LEFT OUTER JOIN, or LEFT JOIN is represented by

This can be performed by specifying how='left'.

left.merge(right, on='key', how='left')

  key   value_x   value_y
0   A  1.764052       NaN
1   B  0.400157  1.867558
2   C  0.978738       NaN
3   D  2.240893 -0.977278

Carefully note the placement of NaNs here. If you specify how='left', then only keys from left are used, and missing data from right is replaced by NaN.

And similarly, for a RIGHT OUTER JOIN, or RIGHT JOIN which is...

...specify how='right':

left.merge(right, on='key', how='right')

  key   value_x   value_y
0   B  0.400157  1.867558
1   D  2.240893 -0.977278
2   E       NaN  0.950088
3   F       NaN -0.151357

Here, keys from right are used, and missing data from left is replaced by NaN.

Finally, for the FULL OUTER JOIN, given by

specify how='outer'.

left.merge(right, on='key', how='outer')

  key   value_x   value_y
0   A  1.764052       NaN
1   B  0.400157  1.867558
2   C  0.978738       NaN
3   D  2.240893 -0.977278
4   E       NaN  0.950088
5   F       NaN -0.151357

This uses the keys from both frames, and NaNs are inserted for missing rows in both.

The documentation summarizes these various merges nicely:

Enter image description here


Other JOINs - LEFT-Excluding, RIGHT-Excluding, and FULL-Excluding/ANTI JOINs

If you need LEFT-Excluding JOINs and RIGHT-Excluding JOINs in two steps.

For LEFT-Excluding JOIN, represented as

Start by performing a LEFT OUTER JOIN and then filtering to rows coming from left only (excluding everything from the right),

(left.merge(right, on='key', how='left', indicator=True)
     .query('_merge == "left_only"')
     .drop('_merge', axis=1))

  key   value_x  value_y
0   A  1.764052      NaN
2   C  0.978738      NaN

Where,

left.merge(right, on='key', how='left', indicator=True)

  key   value_x   value_y     _merge
0   A  1.764052       NaN  left_only
1   B  0.400157  1.867558       both
2   C  0.978738       NaN  left_only
3   D  2.240893 -0.977278       both

And similarly, for a RIGHT-Excluding JOIN,

(left.merge(right, on='key', how='right', indicator=True)
     .query('_merge == "right_only"')
     .drop('_merge', axis=1))

  key  value_x   value_y
2   E      NaN  0.950088
3   F      NaN -0.151357

Lastly, if you are required to do a merge that only retains keys from the left or right, but not both (IOW, performing an ANTI-JOIN),

You can do this in similar fashion—

(left.merge(right, on='key', how='outer', indicator=True)
     .query('_merge != "both"')
     .drop('_merge', axis=1))

  key   value_x   value_y
0   A  1.764052       NaN
2   C  0.978738       NaN
4   E       NaN  0.950088
5   F       NaN -0.151357

Different names for key columns

If the key columns are named differently—for example, left has keyLeft, and right has keyRight instead of key—then you will have to specify left_on and right_on as arguments instead of on:

left2 = left.rename({'key':'keyLeft'}, axis=1)
right2 = right.rename({'key':'keyRight'}, axis=1)

left2

  keyLeft     value
0       A  1.764052
1       B  0.400157
2       C  0.978738
3       D  2.240893

right2

  keyRight     value
0        B  1.867558
1        D -0.977278
2        E  0.950088
3        F -0.151357
left2.merge(right2, left_on='keyLeft', right_on='keyRight', how='inner')

  keyLeft   value_x keyRight   value_y
0       B  0.400157        B  1.867558
1       D  2.240893        D -0.977278

Avoiding duplicate key column in output

When merging on keyLeft from left and keyRight from right, if you only want either of the keyLeft or keyRight (but not both) in the output, you can start by setting the index as a preliminary step.

left3 = left2.set_index('keyLeft')
left3.merge(right2, left_index=True, right_on='keyRight')

    value_x keyRight   value_y
0  0.400157        B  1.867558
1  2.240893        D -0.977278

Contrast this with the output of the command just before (that is, the output of left2.merge(right2, left_on='keyLeft', right_on='keyRight', how='inner')), you'll notice keyLeft is missing. You can figure out what column to keep based on which frame's index is set as the key. This may matter when, say, performing some OUTER JOIN operation.


Merging only a single column from one of the DataFrames

For example, consider

right3 = right.assign(newcol=np.arange(len(right)))
right3
  key     value  newcol
0   B  1.867558       0
1   D -0.977278       1
2   E  0.950088       2
3   F -0.151357       3

If you are required to merge only "newcol" (without any of the other columns), you can usually just subset columns before merging:

left.merge(right3[['key', 'newcol']], on='key')

  key     value  newcol
0   B  0.400157       0
1   D  2.240893       1

If you're doing a LEFT OUTER JOIN, a more performant solution would involve map:

# left['newcol'] = left['key'].map(right3.set_index('key')['newcol']))
left.assign(newcol=left['key'].map(right3.set_index('key')['newcol']))

  key     value  newcol
0   A  1.764052     NaN
1   B  0.400157     0.0
2   C  0.978738     NaN
3   D  2.240893     1.0

As mentioned, this is similar to, but faster than

left.merge(right3[['key', 'newcol']], on='key', how='left')

  key     value  newcol
0   A  1.764052     NaN
1   B  0.400157     0.0
2   C  0.978738     NaN
3   D  2.240893     1.0

Merging on multiple columns

To join on more than one column, specify a list for on (or left_on and right_on, as appropriate).

left.merge(right, on=['key1', 'key2'] ...)

Or, in the event the names are different,

left.merge(right, left_on=['lkey1', 'lkey2'], right_on=['rkey1', 'rkey2'])

Other useful merge* operations and functions

This section only covers the very basics, and is designed to only whet your appetite. For more examples and cases, see the documentation on merge, join, and concat as well as the links to the function specifications.



Continue Reading

Jump to other topics in Pandas Merging 101 to continue learning:

*You are here.

熊猫合并101

怪我太投入 2025-02-14 21:38:04

WaitGroup在此代码中是多余的。执行与正在等待频道结果的循环完美同步。直到所有功能完成工作并从频道读取发布的结果之前,代码才不会向前移动。
仅当您的功能将结果发布到频道后需要进行任何工作时,才有必要。

我也更喜欢实现略有不同的实现。在已发布的实现中,每次执行函数时,我们都不会将结果和错误发送到频道中。相反,我们只能发送成功执行的结果,并在代码失败时仅发送错误。

优势是简化结果/错误处理。没有 nils ,我们将获得结果和错误。

在此示例中,该函数返回一个数字,如果发生错误,我们将其默认值 0 。如果零可能是合法函数执行结果,则无法成功执行未成功执行可能是复杂的。

与错误相同。要检查是否有任何错误,我们可以使用简单的代码,例如如果Len(errs)!= 0

package main

import (
    "fmt"
)

func processBatch(num int, errChan chan<- error, resultChan chan<- int) {
    if num == 3 {
        // no need to send result when it is meanenless
        // resultChan <- 0
        errChan <- fmt.Errorf("goroutine %d's error returned", num)
    } else {
        square := num * num

        resultChan <- square

        // no need to send errror when it is nil
        // errChan <- nil
    }

}

func main() {
    batches := [5]int{1, 2, 3, 4, 5}

    resultChan := make(chan int)
    errChan := make(chan error)

    for i := range batches {
        go processBatch(batches[i], errChan, resultChan)
    }

    // use slices instead of arrays because legth varry now
    var results []int
    var errs []error

    // every time function executes it sends singe piece of data to one of two channels
    for range batches {
        select {
        case res := <-resultChan:
            results = append(results, res)
        case err := <-errChan:
            errs = append(errs, err)
        }
    }

    close(resultChan)
    close(errChan)

    fmt.Println(results)
    fmt.Println(errs)
}

https://go.dev/play/pplay/p/symfl8igxgd

[25 1 16 4]
[goroutine 3's error returned]

我们可以从某些 Multierr 软件包中获得好处。例如, github.com/hashicorp/go-multierror

Waitgroup is redundant in this code. Execution is perfectly synced with the loop that is waiting for the channel's result. Code is not moved forward until all functions finish their work and posted results are read from the channels.
Waitgroup is only necessary if your function needs to do any work AFTER results are posted to channels.

I also prefer a slightly different implementation. In a posted implementation, we are not sending both results and errors into the channels every time when the function is executed. Instead, we can send only the result for successful execution and send only an error when the code fails.

The advantage is simplified results/errors processing. We are getting slices of results and errors without nils.

In this example, the function returns a number, and we send its default value of 0 in case of error. It could be complicated to filter out not successful execution results from successful if zero could be legit function execution result.

Same with errors. To check if we have any errors, we can use simple code like if len(errs) != 0.

package main

import (
    "fmt"
)

func processBatch(num int, errChan chan<- error, resultChan chan<- int) {
    if num == 3 {
        // no need to send result when it is meanenless
        // resultChan <- 0
        errChan <- fmt.Errorf("goroutine %d's error returned", num)
    } else {
        square := num * num

        resultChan <- square

        // no need to send errror when it is nil
        // errChan <- nil
    }

}

func main() {
    batches := [5]int{1, 2, 3, 4, 5}

    resultChan := make(chan int)
    errChan := make(chan error)

    for i := range batches {
        go processBatch(batches[i], errChan, resultChan)
    }

    // use slices instead of arrays because legth varry now
    var results []int
    var errs []error

    // every time function executes it sends singe piece of data to one of two channels
    for range batches {
        select {
        case res := <-resultChan:
            results = append(results, res)
        case err := <-errChan:
            errs = append(errs, err)
        }
    }

    close(resultChan)
    close(errChan)

    fmt.Println(results)
    fmt.Println(errs)
}

https://go.dev/play/p/SYmfl8iGxgD

[25 1 16 4]
[goroutine 3's error returned]

If you can use external packages, we can get benefits from some multierr package. For example, github.com/hashicorp/go-multierror.

惯用的goroutine并发和错误处理

怪我太投入 2025-02-14 20:03:18

使用 Stringr 的另一个选项。 str_remove 将删除下面的第一组数字:

library(stringr)
str="20819830_r1ar_u_stationary"
str_remove(str, "^[0-9]+(?=_)_")
[1] "r1ar_u_stationary"

Another option using stringr. str_remove will remove the first set of digits that are followed by an underscore:

library(stringr)
str="20819830_r1ar_u_stationary"
str_remove(str, "^[0-9]+(?=_)_")
[1] "r1ar_u_stationary"

如何从列名中删除第一组数字?

怪我太投入 2025-02-14 03:47:06

我认为您正在尝试直接访问:

article.blog.document.uid

应用于您的代码:

postPages.data.allPrismicLastPosts.nodes.forEach((page) => {
  page.data.blogs.forEach((article) => {
    createPage({
      path: article.blog.document.uid,
      component: path.resolve(__dirname, "src/templates/post.js"),
      context: {
        id: page.id,
      },
    });
  });
});

I think you are trying to access directly to:

article.blog.document.uid

Applied to your code:

postPages.data.allPrismicLastPosts.nodes.forEach((page) => {
  page.data.blogs.forEach((article) => {
    createPage({
      path: article.blog.document.uid,
      component: path.resolve(__dirname, "src/templates/post.js"),
      context: {
        id: page.id,
      },
    });
  });
});

基于GraphQl查询创建Gatsby节点页

怪我太投入 2025-02-13 07:27:37

这取决于...如果单击事件在冒泡阶段,也许您可​​以在自定义扫描单击事件处理程序中捕获事件。然后,您可以在捕获阶段上添加单击侦听器,该阶段是在冒泡阶段将

elements[i].addEventListener('click', this.preventClick, true);

第三个参数指定为true(usecapture)

It depends...maybe You can catch event before custom-slide click event handler recives it if click event is on bubbling phase. then you can add your click-prevent listener on capturing phase which comes before bubbling phase

elements[i].addEventListener('click', this.preventClick, true);

specify third parameter as true (useCapture)

在幻灯片中,我如何防止幻灯片接收“单击”。拖动后的事件?

怪我太投入 2025-02-12 08:54:51

当您使用付款关键字定义功能时,这意味着该功能希望从WEI中接收值。部署合同后,您会注意到,这将为您的方法添加一个参数。传递的值可以是任何数量的以太,甚至零,这是您的 requient 语句发挥作用的地方。

当您在类似 buyland 之类的方法中调用付款()函数时,这允许合同将以太发送到第一个参数中指定的地址,或者在您的情况下<代码> Landownermagping [_landid] 。

基本上,这是使用付款作为关键字之间的区别,并将其用作方法。您可以在“坚固性文档”中找到有关它的更多信息。

When you define a function with the payable keyword, this means that the function expects to receive a value in terms of Wei. You will notice after deploying your contract that this adds a parameter to your method. The value passed can be any amount of Ether, even zero, and this is where your require statement comes into play.

When you call the payable() function inside a method like in BuyLand, this allows the contract to send Ether to the address specified in the first parameter, or in your case landOwnerMapping[_landId].

Basically it's the difference between using payable as a keyword, and using it as a method. You can find out more about it in the solidity documents.

固体的应付功能如何通过msg.value方法获得金钱?

怪我太投入 2025-02-11 08:17:22

因此,基于您给出的单个示例,也没有对更改位置的假设:

“在此处输入图像说明”

您可以编辑通过使用Len()扩展技术来处理可能包含额外数字等的任何数字并在必要时找到()。

So, based on the single example you gave and making no assumptions about changing positions:

enter image description here

You can edit to deal with any of the numbers that may contain extra digits etc by expanding on the technique using len() and find() as necessary.

在某些条件下提取子字

怪我太投入 2025-02-11 00:39:46

替换:

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.SEND"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="message/rfc822"/>
        </intent-filter>
    </activity>

用:

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="message/rfc822"/>
        </intent-filter>
    </activity>

Replace:

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.SEND"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="message/rfc822"/>
        </intent-filter>
    </activity>

with:

    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="message/rfc822"/>
        </intent-filter>
    </activity>

应用程序运行,但dosent有一个位置

怪我太投入 2025-02-10 05:34:32

爆炸结果要使它们进入行,

df = spark.read.json("./sample.json", multiLine=True)
df2 = df.withColumn('d', explode(col('d.results')))
df2.select(df2.d.userId, df2.d.startDate).show(10,False)

+--------+---------------------+
|d.userId|d.startDate          |
+--------+---------------------+
|60000033|/Date(1659398400000)/|
|100003  |/Date(1635724800000)/|
+--------+---------------------+

您可以根据需要添加任务多属性

df.select(explode(col('d.results'))).\
    selectExpr("col.userId","col.startDate","col.lastModifiedBy").\
    show(10,False)

+--------+---------------------+--------------+
|userId  |startDate            |lastModifiedBy|
+--------+---------------------+--------------+
|60000033|/Date(1659398400000)/|This Dude     |
|100003  |/Date(1635724800000)/|This Dudette  |
+--------+---------------------+--------------+

Explode results to get them into row

df = spark.read.json("./sample.json", multiLine=True)
df2 = df.withColumn('d', explode(col('d.results')))
df2.select(df2.d.userId, df2.d.startDate).show(10,False)

+--------+---------------------+
|d.userId|d.startDate          |
+--------+---------------------+
|60000033|/Date(1659398400000)/|
|100003  |/Date(1635724800000)/|
+--------+---------------------+

You can add as many attributes as required e.g

df.select(explode(col('d.results'))).\
    selectExpr("col.userId","col.startDate","col.lastModifiedBy").\
    show(10,False)

+--------+---------------------+--------------+
|userId  |startDate            |lastModifiedBy|
+--------+---------------------+--------------+
|60000033|/Date(1659398400000)/|This Dude     |
|100003  |/Date(1635724800000)/|This Dudette  |
+--------+---------------------+--------------+

使用Pyspark在Azure Databrick中的数据框中,将复杂的JSON对象从Web API转换为多行?

怪我太投入 2025-02-10 02:37:00

不确定您要查找的结果,但是以下代码将生成带有栏的图形,每年发布的标准。

const labels = ["2018", "2019", "2020", "2021", "2022"];

export const data = {
  labels,
  datasets: [
    {
      label: "Released",
      data: products.map(p => p.status === "released" ? 1:0),
      backgroundColor: "rgba(255, 99, 132, 0.5)"
    }
  ]
};

export function App() {
  return <Bar options={options} data={data} />;
}

Not sure the result you are looking for, but the following code will generate a graph with a bar for each year that was released.

const labels = ["2018", "2019", "2020", "2021", "2022"];

export const data = {
  labels,
  datasets: [
    {
      label: "Released",
      data: products.map(p => p.status === "released" ? 1:0),
      backgroundColor: "rgba(255, 99, 132, 0.5)"
    }
  ]
};

export function App() {
  return <Bar options={options} data={data} />;
}

React-Chartjs-2:如何在条形图中显示过去5年中发布的日期的时间表?

怪我太投入 2025-02-09 22:04:01
foreach ($itemcodes as $i => $item_code) {
     $tmp = [
       'warr_item_code'            => $item_code,
       'warr_item_category'        => $request->itemcategory[$i],
       'warr_item_name'            => $request->itemname[$i],
       'warr_item_qty'             => $request->itemqty[$i],
       'warr_item_condition'       => $request->itemcondition[$i],
       'warr_item_origin'          => $request->itemorigin[$i],
       'warr_item_purchase_year'   => $request->itempurchaseyear[$i],
    ];

    if ($request->hasfile($request->itemimg[$i])) {
       $file               = $request->file($request->itemimg[$i]),
       $extension          = $file->getClientOriginalExtension(),
       $img                = time() . '.' . $extension;
       $file->move('dist/images/data-barang/', $img);
       $pathOfImage = 'dist/images/data-barang/' . $img;
       $tmp['warr_item_img']     = $pathOfImage ;
    } else {
       $tmp['warr_item_img']     = '';
    }
    $order_detail[] = $tmp   
}

您应该使用路径而不是绝对路径 /strong>

foreach ($itemcodes as $i => $item_code) {
     $tmp = [
       'warr_item_code'            => $item_code,
       'warr_item_category'        => $request->itemcategory[$i],
       'warr_item_name'            => $request->itemname[$i],
       'warr_item_qty'             => $request->itemqty[$i],
       'warr_item_condition'       => $request->itemcondition[$i],
       'warr_item_origin'          => $request->itemorigin[$i],
       'warr_item_purchase_year'   => $request->itempurchaseyear[$i],
    ];

    if ($request->hasfile($request->itemimg[$i])) {
       $file               = $request->file($request->itemimg[$i]),
       $extension          = $file->getClientOriginalExtension(),
       $img                = time() . '.' . $extension;
       $file->move('dist/images/data-barang/', $img);
       $pathOfImage = 'dist/images/data-barang/' . $img;
       $tmp['warr_item_img']     = $pathOfImage ;
    } else {
       $tmp['warr_item_img']     = '';
    }
    $order_detail[] = $tmp   
}

You should use path instead of absolute path

如何将图像添加到Laravel中的数组

怪我太投入 2025-02-09 11:46:22

您不能将字符串直接传递到 pngoutputter 。必须先通过Barby的QR码模块处理。

require 'barby'
require 'rqrcode'
require 'barby/barcode/qr_code'
require 'barby/outputter/png_outputter'
qr_string = "8076809574693\r\n8076809574693\r\n8076809574693\r\n4017100364013\r\n4017100364013\r\n3017760002707\r\n8076809517706\r\n8013355999488\r\n"
qr_data = Barby::QrCode.new(qr_string)
qr_output = Barby::PngOutputter.new(qr_data).to_png
File.open('qrcode.png', 'wb'){|f| f.write qr_output }

You can't pass a string directrly to PngOutputter. It must be processed by barby's qr code module first.

require 'barby'
require 'rqrcode'
require 'barby/barcode/qr_code'
require 'barby/outputter/png_outputter'
qr_string = "8076809574693\r\n8076809574693\r\n8076809574693\r\n4017100364013\r\n4017100364013\r\n3017760002707\r\n8076809517706\r\n8013355999488\r\n"
qr_data = Barby::QrCode.new(qr_string)
qr_output = Barby::PngOutputter.new(qr_data).to_png
File.open('qrcode.png', 'wb'){|f| f.write qr_output }

barby gem不生成qr_code

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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