漫雪独思

文章 评论 浏览 29

漫雪独思 2025-02-01 16:36:09

不可能。在2D图中,该区域就像空白处,您无法选择它。

It's not possible. In a 2D drawing, that region is like empty space, you can't select it.

在Autodesk Forge 2D .DWG图纸中,空间/区域选择可能吗?

漫雪独思 2025-01-31 20:34:41

您也可以只使用unders_name并使用iLoc成人_NAME[11]exucter_name.iloc [2]相同。 ILOC是按位置索引。

you could also just use adults_name and use the iloc. adult_name[11] is the same as adult_name.iloc[2]. iloc is indexing by position.

关于从数据框中选择行和列的问题(Python)

漫雪独思 2025-01-31 10:01:05

尝试一下,有点不同,但应该做同样的事情:

function isSpecialNumber(n) {
  // n.toString() turns the number into a string
  // .split('') splits the string into an array
  // .every loops through the items in an array and
  // checks that all the elements return true for the function that
  // passed as the parameter into the every function.
  // .every doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
  const special = n.toString()
    .split()
    .every((digit) => parseInt(digit) < 5)

  // You can also do this, which uses .some
  // .some doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
  /*
  const special = n.toString()
    .split()
    .some((digit) => parseInt(digit) > 5)
  */
  
  // if all the digits are less than 5, then it's special
  // and should return "Special!!"
  // else, return "NOT!!"
  return special ? "Special!!" : "NOT!!"
}

console.log(
  isSpecialNumber(144525),
  isSpecialNumber(2),
  isSpecialNumber(9),
  isSpecialNumber(23),
  isSpecialNumber(39)
)

Try this, it's a little bit different but it should do the same:

function isSpecialNumber(n) {
  // n.toString() turns the number into a string
  // .split('') splits the string into an array
  // .every loops through the items in an array and
  // checks that all the elements return true for the function that
  // passed as the parameter into the every function.
  // .every doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
  const special = n.toString()
    .split()
    .every((digit) => parseInt(digit) < 5)

  // You can also do this, which uses .some
  // .some doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
  /*
  const special = n.toString()
    .split()
    .some((digit) => parseInt(digit) > 5)
  */
  
  // if all the digits are less than 5, then it's special
  // and should return "Special!!"
  // else, return "NOT!!"
  return special ? "Special!!" : "NOT!!"
}

console.log(
  isSpecialNumber(144525),
  isSpecialNumber(2),
  isSpecialNumber(9),
  isSpecialNumber(23),
  isSpecialNumber(39)
)

功能ISSPECIALNUMBER(N)不给出所需的结果

漫雪独思 2025-01-31 05:01:28

我在Github上问了这个问题,创建者Paulledemon更新了项目以允许此问题。

最低版本:2.0.2

您可以使用sethours(10)将小时设置为10和setMinutes(50)将分钟设置为50。模拟式票房将其用于期限默认设置为AM的参数。您可以使用AlalogPicker(parent,ofere,ofend = startants.pm)

代码示例:

from tkinter import *
from tktimepicker import AnalogPicker, AnalogThemes, constants



def pick_time():

    toplevel = Toplevel(root)
    
    picker = AnalogPicker(toplevel, period=constants.PM) #take out 'period=constants.PM' to change to AM
    picker.setHours(10) #set the hour to 10
    picker.setMinutes(45) #set the minutes to 45

    picker.pack(fill="both", expand=True)
    theme = AnalogThemes(picker)
    theme.setNavyBlue()


root = Tk()

btn = Button(text="pick time", command=pick_time)
btn.pack()

root.mainloop()

I asked this question on github, and PaulleDemon, the creator, updated the project to allow this.

Minimum version: 2.0.2

You can use setHours(10) to set the hour to 10 and setMinutes(50) to set the minutes to 50. AnalogPicker takes period as a parameter which is set to AM by default. You can change this to PM using AnalogPicker(parent, period=constants.PM)

Code example:

from tkinter import *
from tktimepicker import AnalogPicker, AnalogThemes, constants



def pick_time():

    toplevel = Toplevel(root)
    
    picker = AnalogPicker(toplevel, period=constants.PM) #take out 'period=constants.PM' to change to AM
    picker.setHours(10) #set the hour to 10
    picker.setMinutes(45) #set the minutes to 45

    picker.pack(fill="both", expand=True)
    theme = AnalogThemes(picker)
    theme.setNavyBlue()


root = Tk()

btn = Button(text="pick time", command=pick_time)
btn.pack()

root.mainloop()

如何更改TKTimePicker模拟时钟的默认时间

漫雪独思 2025-01-30 18:11:28

一种方法是,让 yq 输出每个键/在以下语法中,在单行上的值对:

key@value

然后我们可以使用 bash的ifs 拆分这些值。
@只是一个示例,可以用任何单一的char 替换


,但请注意以下限制

  • 它不会期望嵌套嵌套值,只有一个平面列表`
  • the字段隔离器(示例中的@)不存在于yaml键/值中

#!/bin/bash

declare -A arr
while IFS="@" read -r key value
do
    arr[$key]="$value"
done < <(yq e 'to_entries | .[] | (.key + "@" + .value)' input.yaml)

for key in "${!arr[@]}"
do
    echo "key  : $key"
    echo "value: ${arr[$key]}"
done
$ cat input.yaml
---
a: "bar"
b: "foo"

$
$
$ ./script.sh
key  : a
value: bar
key  : b
value: foo
$

One way, is by letting output each key/value pair on a single line, in the following syntax:

key@value

Then we can use bash's IFS to split those values.
The @ is just an example and can be replaced with any single char


This works, but please note the following limitations:

  • It does not expect nested values, only a flat list`
  • The field seperator (@ in the example) does not exist in the YAML key/value's

#!/bin/bash

declare -A arr
while IFS="@" read -r key value
do
    arr[$key]="$value"
done < <(yq e 'to_entries | .[] | (.key + "@" + .value)' input.yaml)

for key in "${!arr[@]}"
do
    echo "key  : $key"
    echo "value: ${arr[$key]}"
done
$ cat input.yaml
---
a: "bar"
b: "foo"

$
$
$ ./script.sh
key  : a
value: bar
key  : b
value: foo
$

如何将yaml文件读取到bash关联数组中?

漫雪独思 2025-01-30 16:13:05

因此,为了完整。正如用户woxxom在问题的评论中提到的那样。 PunyCode是国际化领域的解决方案。

因此,为了匹配tlds em детиi,我使用了此正则:

^(.*):\/\/(.*).(ru|su|tatar|xn--p1ai|xn--d1acj3b)\/(.*)

我将其转换为punycode, https://www.punycoder.com/

So for the sake of completeness. As user wOxxOm mentioned in the comments of the question. Punycode is the solution in cases of internationalized domains.

So in order to match the TLDs рф and детиI I used this regex instead:

^(.*):\/\/(.*).(ru|su|tatar|xn--p1ai|xn--d1acj3b)\/(.*)

I converted it to Punycode using, https://www.punycoder.com/.

如何将非ASCII字符在DECLARATIVENETREQUEST API的REGEX过滤器中用于Google Chrome扩展名?

漫雪独思 2025-01-30 15:48:27

node.error()的第一个参数应为字符串,而不是对象。这是因为它明确表示是人类可读的消息

只需在第二个实例中做您所做的事情,但请包括一条短信以与错误有关:

const object = {
   "key1": "value1", 
   "key2": "value2"
}
msg.error = object

node.error("Some error message",msg)

The first argument to node.error() should be a string, not an object. This is because it is explicitly meant to be a human readable message.

Just do what you have done in the second instance, but include a text message to go with the error:

const object = {
   "key1": "value1", 
   "key2": "value2"
}
msg.error = object

node.error("Some error message",msg)

是否可以使用node.error()函数在节点red上捕获对象?

漫雪独思 2025-01-30 10:31:01

假设您只需要在“玩具X”中查看,则可以迭代dict中的值。

from statistics import mean
from collections import defaultdict

def get_mean_price_by_submodel(data):
    r = defaultdict(list)
    for v in data.values():
        r[v["submodel"]].append(v["price"])
    return {k: mean(v) for k, v in r}

data = request.get("toysforyou").json()
print(prices_by_submodel(data["Toy X"]))

最好分别请求和解析JSON(这可以在一行data = request.get(“ ToysForyou”)。json()()())中进行,然后仅将所需的字典发送到该函数。

或者,将您的JSON转换为PANDAS DataFrame,尤其是在进行大量数据操纵和分析时。

import pandas as pd
df = pd.DataFrame.from_dict(data["Toy X"], orient="index")
print(df.groupby("submodel").mean("price"))

Assuming you only need to look within "Toy X", you can iterate over the values in the dict, like this.

from statistics import mean
from collections import defaultdict

def get_mean_price_by_submodel(data):
    r = defaultdict(list)
    for v in data.values():
        r[v["submodel"]].append(v["price"])
    return {k: mean(v) for k, v in r}

data = request.get("toysforyou").json()
print(prices_by_submodel(data["Toy X"]))

It's best to request and parse the JSON separately (this can be done in one line data = request.get("toysforyou").json()) and send only the required dictionary to the function.

Alternatively, convert your JSON to a pandas dataframe, especially if you are doing substantial data manipulation and analysis.

import pandas as pd
df = pd.DataFrame.from_dict(data["Toy X"], orient="index")
print(df.groupby("submodel").mean("price"))

Python JSON API解析

漫雪独思 2025-01-30 09:30:41

从C ++ 20开始,您可以使用auto作为函数参数:

void product(auto &arr, auto &arr1)

您可以使用std :: size(arr)获得第一个索引和<第二个索引的代码> std :: size(*arr)。

完成程序:

#include <iostream>

using namespace std;

void product(auto &arr, auto &arr1)
{
   for (const auto &inner: arr)
   for (const auto &elem: inner)
   {
     cout << "arr[][] is " << elem << endl;
   }


   for (const auto &inner: arr1)
   for (const auto &elem: inner)
   {
     cout << "arr1[][] is " << elem << endl;
   }

   cout << "size of arr " << size(arr) << " * " << size(*arr) << endl;
   cout << "size of arr " << size(arr1) << " * " << size(*arr1) << endl;
}

int main()
{
    int A[2][2] = { { 1, 2 }, { 3, 4 }};
    int B[3][1] = { { 0}, { 6 }, {3} };

    product(A,B);
    return 0;
}

https://godbolt.org/z/7a31515erhf

Starting with C++20 you can use auto as type for function parameters:

void product(auto &arr, auto &arr1)

You can get the array sizes with std::size(arr) for the first index and std::size(*arr) for the second index.

Complete program:

#include <iostream>

using namespace std;

void product(auto &arr, auto &arr1)
{
   for (const auto &inner: arr)
   for (const auto &elem: inner)
   {
     cout << "arr[][] is " << elem << endl;
   }


   for (const auto &inner: arr1)
   for (const auto &elem: inner)
   {
     cout << "arr1[][] is " << elem << endl;
   }

   cout << "size of arr " << size(arr) << " * " << size(*arr) << endl;
   cout << "size of arr " << size(arr1) << " * " << size(*arr1) << endl;
}

int main()
{
    int A[2][2] = { { 1, 2 }, { 3, 4 }};
    int B[3][1] = { { 0}, { 6 }, {3} };

    product(A,B);
    return 0;
}

https://godbolt.org/z/7a315erhf

使用C&#x2B;&#x2B中的模板传递2个不同尺寸的数组

漫雪独思 2025-01-30 08:51:21

简短的答案是,您必须实现这样的回调:

function callback(response) {
    // Here you can do what ever you want with the response object.
    console.log(response);
}

$.ajax({
    url: "...",
    success: callback
});

The short answer is, you have to implement a callback like this:

function callback(response) {
    // Here you can do what ever you want with the response object.
    console.log(response);
}

$.ajax({
    url: "...",
    success: callback
});

如何从异步电话中返回响应?

漫雪独思 2025-01-29 19:44:57

考虑一下功能指针不是魔术,他们仍然必须遵守ABI调用惯例,这意味着具有一定签名的函数与具有不同签名的函数本质上不同。

使用功能指针更多的是使用动态方法,而不是实现多态性。编辑:这不是多态性。

但是,您可以通过更换每个测试功能来接受void*,然后在结构中编码您的参数来完成一些问题。

// Declare the test functions

//bool test1();
bool test1(void* struct_address)
{
    // struct address unused.
}

// Parameters for test2
struct test2{
    char const* string;
    uint32_t*   length;
}

//bool test2(char const *string, uint32_t length);
bool test2(void* struct_address)
{
    struct test2 test2_s = *(struct test2*)(struct_address);

    // Work with test2_s
}

// Declare the function pointer 
bool (*test_ptr)(void *);

// call test1
test_ptr = test1; test_ptr((void*)NULL);

// call test2
struct test2 test2_s = {param1,param2};
test_ptr = test2; test_ptr((void*)&test2_s);

请小心,因为如果您传递了错误的结构类型,则会获得内存泄漏和细分错误。但是,由于这是一个测试环境,因此可以缓解这一点。

Consider that function pointers are not magic tricks, they still have to abide to the ABI calling convention, meaning that a function with a certain signature is intrinsically different from a function with a different signature.

Using a function pointer is more of a way to have dynamic methods, than to achieve polymorphism. EDIT: This is not polymorphism.

However, you can accomplish somewhat you ask by replacing each of the test functions to accept a void* and then code your parameters in a struct.

// Declare the test functions

//bool test1();
bool test1(void* struct_address)
{
    // struct address unused.
}

// Parameters for test2
struct test2{
    char const* string;
    uint32_t*   length;
}

//bool test2(char const *string, uint32_t length);
bool test2(void* struct_address)
{
    struct test2 test2_s = *(struct test2*)(struct_address);

    // Work with test2_s
}

// Declare the function pointer 
bool (*test_ptr)(void *);

// call test1
test_ptr = test1; test_ptr((void*)NULL);

// call test2
struct test2 test2_s = {param1,param2};
test_ptr = test2; test_ptr((void*)&test2_s);

Be careful because if you pass the wrong struct type you will get memory leaks and segmentation errors. Since this is a test environment, however, this can be mitigated.

如何为具有不同参数的函数声明一系列函数指针?

漫雪独思 2025-01-29 15:26:19

请尝试此 tflite_flutter 通过将此插件添加到您的pubspec.yaml文件

在此处输入图像描述

Please try this tflite_flutter by adding this plugin to your pubspec.yaml file

enter image description here

构建因使用不推荐的Android V1嵌入而失败

漫雪独思 2025-01-29 14:18:17

请在下面找到校正的代码,

Object.fromEntries(TestArray.map((item) => {
  if (!(parseInt(item["validTo"]) > item["Time"])) {
    return [item["Time"], item["value"]]
  }
}).filter(item => item))

我已经看到您已经了解了为什么您的代码不适用于上面的评论。

Please find the corrected code below

Object.fromEntries(TestArray.map((item) => {
  if (!(parseInt(item["validTo"]) > item["Time"])) {
    return [item["Time"], item["value"]]
  }
}).filter(item => item))

I have seen that you have already understood why your code did not work with the comments above.

Unturect typeerror:迭代器值不确定不是入口对象。将过滤器添加到映射

漫雪独思 2025-01-29 14:09:33

您可以使用a filter

carbs = list(filter(lambda x:x ['name'] =='碳水化合物',response.json()['nutrition'] ['nutrients'])))

更紧凑。您获得的输出是

[{'name':'碳水化合物','量':23.0,'unit':'g','百分比dailyneeds':7.67}]

You can do this with a filter too, which would look something like this

carbs = list(filter(lambda x: x['name'] == 'Carbohydrates', response.json()['nutrition']['nutrients']))

Which is a bit more compact. The output you get is

[{'name': 'Carbohydrates', 'amount': 23.0, 'unit': 'g', 'percentOfDailyNeeds': 7.67}]

提取括号内的数据

漫雪独思 2025-01-29 10:43:37

因此您可以使用以下查询

select 
t1.date, 
t1.Name, 
t1.cost,
IFNULL(t2.tags,'(not set)')
 from table1 t1 left outer join
table2 t2 on t1.name=t2.name and t1.date>=t2.date

so you can use a query like below

select 
t1.date, 
t1.Name, 
t1.cost,
IFNULL(t2.tags,'(not set)')
 from table1 t1 left outer join
table2 t2 on t1.name=t2.name and t1.date>=t2.date

BigQuery根据条件加入桌子

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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