还在原地等你

文章 评论 浏览 29

还在原地等你 2025-02-09 12:05:37

这应该是更快的

idx_cols = ['date','person','weather']
idx = pd.MultiIndex.from_frame(df[idx_cols])

df_transformed = (
    df.loc[df.event == 'sneeze', idx_cols]
      .value_counts()
      .reindex(idx, fill_value=0)
      .reset_index()
)

输出:

>>> df_transformed

         date person weather  0
0  2012-03-30   dave   rainy  1
1  2012-03-30   mike   sunny  0
2  2012-03-30   mike  cloudy  1
3  2012-03-30   dave  cloudy  1
4  2012-03-30   mike   rainy  0
5  2012-03-31   dave   sunny  0
6  2012-03-31   dave  cloudy  1
7  2012-03-31   dave   sunny  0
8  2012-03-31   mike  cloudy  1
9  2012-03-31   mike   rainy  1

其他选项是使用 Merge

idx_cols = ['date','person','weather']

counts = (
    df.loc[df.event == 'sneeze', idx_cols]
      .value_counts()
      .reset_index()
)

df_transformed = ( 
    df[idx_cols].merge(counts, on=idx_cols, how='left')
                .fillna(0)
                .astype({0: int})  # convert the type of the new column (labeled 0) to int. It was float due to NaNs 
)

我过度复杂...实际上,这种方式更加简单

idx_cols = ['date','person','weather']

df_transformed = (
    df.assign(is_sneeze=(df.event == 'sneeze'))
      .groupby(idx_cols, as_index=False)['is_sneeze']
      .sum()
)

This should be faster

idx_cols = ['date','person','weather']
idx = pd.MultiIndex.from_frame(df[idx_cols])

df_transformed = (
    df.loc[df.event == 'sneeze', idx_cols]
      .value_counts()
      .reindex(idx, fill_value=0)
      .reset_index()
)

Output:

>>> df_transformed

         date person weather  0
0  2012-03-30   dave   rainy  1
1  2012-03-30   mike   sunny  0
2  2012-03-30   mike  cloudy  1
3  2012-03-30   dave  cloudy  1
4  2012-03-30   mike   rainy  0
5  2012-03-31   dave   sunny  0
6  2012-03-31   dave  cloudy  1
7  2012-03-31   dave   sunny  0
8  2012-03-31   mike  cloudy  1
9  2012-03-31   mike   rainy  1

Other option is to use merge

idx_cols = ['date','person','weather']

counts = (
    df.loc[df.event == 'sneeze', idx_cols]
      .value_counts()
      .reset_index()
)

df_transformed = ( 
    df[idx_cols].merge(counts, on=idx_cols, how='left')
                .fillna(0)
                .astype({0: int})  # convert the type of the new column (labeled 0) to int. It was float due to NaNs 
)

I was overcomplicating... actually, this way is much more straightforward

idx_cols = ['date','person','weather']

df_transformed = (
    df.assign(is_sneeze=(df.event == 'sneeze'))
      .groupby(idx_cols, as_index=False)['is_sneeze']
      .sum()
)

什么是pandas中每个组中特定值的发生,过滤和计算特定值的有效方法?

还在原地等你 2025-02-08 22:29:19

tl; dr

  • 这个概念是“ C#标记”。
  • 入门:右键单击项目 - >添加 - >新项目 - > .net maui-> .net MAUI ContentPage(C#) .net Maui ContentView(C#)
  • 如果毛伊文档尚未(尚未)拥有所需的信息,则Google Xamarin形式的someuelement类 someuielement api。

MAUI“ API”文档还不存在(目前只有一个页面给出“更高级别”的解释),因此可以通过搜索相应的Xamarin表单class 来找到更多信息。
Google Xamarin表单contentpage类查找:


在那里,我们看到c#示例:

using System;
using Xamarin.Forms;

namespace ContentPageExample
{
    public class App : Application
    {
        public static Page GetMainPage ()
        {    
            return new ContentPage { 
                Content = new Label {
                    Text = "Hello, Forms!",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };
        }

        public App ()
        {
            MainPage = GetMainPage();
        }
    }
}

app 详细信息可能会略有不同。我们关心的该代码的一部分是:

            return new ContentPage { 
                Content = new Label {
                    Text = "Hello, Forms!",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };

这在毛伊岛的工作。 (编译器警告说 layoutoptions.centerandexpand 被弃用;但是讨论这超出了此答案的范围。)


可重复使用的视图

如果您想引用XAML中其他地方的UI元素或代码,定义现有UI元素的子类。

感谢Paramjit指出的第一步是将适当的项目添加到项目中。对于 contentpage ,也就是:

右键单击project->添加 - >新项目 - > .net maui-> .NET MAUI ContentPage(C#)

for ContentView (如下),该步骤是:

右键单击project->添加 - >新项目 - > .net maui-> .NET MAUI ContentView(C#)


源文件mycontentview.cs:

namespace MyViews
{
    public class MyContentView : ContentView
    {
        public MyContentView {
            //NO "InitializeComponent()" because doing it all in c#.

            Content = new Label {
                Text = "Hello, Maui!"
            }
        }
    }
}

xaml中的用法:

<SomeClass ...
    xmlns:myviews="clr-namespace:MyViews"
    ...>
    ...
    <myviews:MyContentView ... />
</SomeClass>

在C#中用法作为C#标记的一部分:

using MyViews;

    ...
    var page = new ContentPage {
        Content = new MyContentView()
    }

Advanced Advanced

subclassing content> ContentView 是在毛伊岛建立“自定义控制”的一种方法。

  • 要定义自定义属性,请阅读有关“自定义视图”和“ Bindable Properties”的信息。 (我目前没有具体的链接。随时添加评论等链接。)


  • 参见创建.net maui maps映射控制

更多信息

定义C#中的UI元素称为“ C#标记”。

请参阅在xamarin.forms.forms.forms.forms 中介绍C#markup 。

Xamarin社区工具包C#markup 。注意:不再需要提到的nuget

tl;dr

  • The concept is "c# markup".
  • Getting started: Right click on project-> Add -> New Item -> .NET MAUI-> .NET MAUI ContentPage (C#) or .NET MAUI ContentView (C#).
  • If a Maui doc doesn't (yet) have the info you need, google xamarin forms SomeUIElement class for the SomeUIElement API.

Maui "API" docs aren't there yet (currently there is only a page giving "higher-level" explanation of each class), so more information can be found by searching for the corresponding Xamarin Forms class.
Google xamarin forms contentpage class to find:

Xamarin.Forms / ContentPage Class.

There, we see c# example:

using System;
using Xamarin.Forms;

namespace ContentPageExample
{
    public class App : Application
    {
        public static Page GetMainPage ()
        {    
            return new ContentPage { 
                Content = new Label {
                    Text = "Hello, Forms!",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };
        }

        public App ()
        {
            MainPage = GetMainPage();
        }
    }
}

The App details may be slightly different for Maui; the part of this code we care about is:

            return new ContentPage { 
                Content = new Label {
                    Text = "Hello, Forms!",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };

This works as-is in Maui. (Compiler warns that LayoutOptions.CenterAndExpand is deprecated; but discussing that is beyond scope of this answer.)


REUSABLE VIEW

If you want to refer to a UI element from elsewhere in xaml or code, define a subclass of an existing UI element.

Thanks to Paramjit for pointing out that the first step is to Add the appropriate item to project. For ContentPage, that is:

Right click on project-> Add -> New Item -> .NET MAUI-> .NET MAUI ContentPage (C#)

For ContentView (as below), that step is:

Right click on project-> Add -> New Item -> .NET MAUI-> .NET MAUI ContentView (C#)


Source file MyContentView.cs:

namespace MyViews
{
    public class MyContentView : ContentView
    {
        public MyContentView {
            //NO "InitializeComponent()" because doing it all in c#.

            Content = new Label {
                Text = "Hello, Maui!"
            }
        }
    }
}

Usage in XAML:

<SomeClass ...
    xmlns:myviews="clr-namespace:MyViews"
    ...>
    ...
    <myviews:MyContentView ... />
</SomeClass>

Usage in c# as part of c# markup:

using MyViews;

    ...
    var page = new ContentPage {
        Content = new MyContentView()
    }

ADVANCED

Subclassing ContentView is one way to make a "custom control" in Maui.

  • To define custom properties, read about "custom views" and "BindableProperties". (I don't have specific links to recommend at this time. Feel free to add such links as comments.)

  • A more advanced way is to create a custom handler.
    See Creating a .NET MAUI Maps Control.


MORE INFO

Defining UI elements in c# is referred to as "c# markup".

See Introducing C# Markup for Xamarin.Forms.

And Xamarin Community Toolkit C# Markup. NOTE: The Nuget mentioned there is no longer required.

如何使用C#而不是XAML创建.NET MAUI ContentPage?

还在原地等你 2025-02-08 11:02:41

只需使用 $ add $ concatrays 来解决此处的数据

db.collection.update({
  id: 1
},
[
  {
    "$addFields": {
      "txnAmt": <amount you want>
    }
  },
  {
    $addFields: {
      balance: {
        $add: [
          "$balance",
          "$txnAmt"
        ]
      }
    }
  },
  {
    "$addFields": {
      "transactions": {
        "$concatArrays": [
          "$transactions",
          [
            {
              balance: "$balance",
              transaction_amount: "$txnAmt"
            }
          ]
        ]
      }
    }
  },
  {
    "$unset": "txnAmt"
  }
],
{
  multi: true
})

蒙哥游乐场供您参考。

Simply use $add and $concatArrays to wrangle the data

db.collection.update({
  id: 1
},
[
  {
    "$addFields": {
      "txnAmt": <amount you want>
    }
  },
  {
    $addFields: {
      balance: {
        $add: [
          "$balance",
          "$txnAmt"
        ]
      }
    }
  },
  {
    "$addFields": {
      "transactions": {
        "$concatArrays": [
          "$transactions",
          [
            {
              balance: "$balance",
              transaction_amount: "$txnAmt"
            }
          ]
        ]
      }
    }
  },
  {
    "$unset": "txnAmt"
  }
],
{
  multi: true
})

Here is the Mongo playground for your reference.

将对象推入MongoDB数组,其中包含来自父档的值

还在原地等你 2025-02-08 05:27:12

存在以下问题:

  • _size 是一个实例属性,该属性是在 __ INT __ INT __ 函数中设置的。这意味着 self._size 将参考该属性,而不是具有相同名称的类方法。这是您遇到的错误的原因。您应该对这两件事使用其他名称:整数大小的一个名称,而对于辅助功能的另一个名称将递归计算大小。我建议使用 _sizerecur 作为助手方法的名称 - 并将在下一个点引用:

  • self._sizerecur(self,0,0,self._root) 不应将 self 作为参数传递,因为该参数已经通过这种类型的方法call语法获得 self 的值(点表示法中的前缀作为该参数)。

  • 如果current_node!= none 应该在其块中具有所有该代码的其余部分,否则 current_node.left Current> Current_node 是,导致错误。


  • 尺寸未正确计算。实质上有两种实施此递归的方法,您的代码似乎都混合在一起,使其不正确:当您将当前大小作为参数传递给递归调用,而该调用将返回更新的值,您不应将其添加到您已经传递给它的原始尺寸中。通过这样做,您有双重计数。您应该将分配它回到您的变量(不添加到它),(更好),而不是将当前的计数作为参数传递,而是让每个递归呼叫开始从0。

    计数

这是一个校正,使现有 current_size 参数:

    def size(self) -> int:
        if self._root is None:
            return 0
        else:
            return self._sizerecur(0, self._root) # don't pass self as arg

    # A distinct name for this method
    def _sizerecur(self, current_size, current_node):
        if current_node:
            current_size += 1
        if current_node.left:
            # don't ADD again to current size
            current_size = self._sizerecur(current_size, current_node.left)
        if current_node.right:
            current_size = self._sizerecur(current_size, current_node.right)

        return current_size

但是,如上所述,在没有 current_size 参数的情况下实现此递归函数是更好的做法。更深入的 recur recur em out 递归,而不是更新计数器:

    def size(self) -> int:
        if self._root is None:
            return 0
        else:
            return self._sizerecur(self._root)

    def _sizerecur(self, current_node):
        current_size = 0
        if current_node:
            current_size = 1
            if current_node.left:
                current_size += self._sizerecur(current_node.left)
            if current_node.right:
                current_size += self._sizerecur(current_node.right)
        return current_size

There are the following issues:

  • _size is an instance attribute that is set in the __init__ function. That means that self._size will refer to that attribute, and not to the class method with the same name. This is the cause of the error you get. You should use a different name for these two things: one name for the integer size, and another for the helper function that will calculate the size recursively. I suggest to use _sizerecur as name for the helper method -- and will refer to it that way in the next point:

  • self._sizerecur(self, 0, self._root) should not pass self as argument, as that parameter is already getting the value of self by this type of method-call syntax (the prefix in the dot notation serves as that argument).

  • if current_node != None should have all the rest of that code in its block, otherwise current_node.left will still be evaluated when current_node is None, leading to an error.

  • The size is not calculated correctly. There are essentially two ways to implement this recursion, and your code seems to mix both of these, making it incorrect: When you pass the current size as argument to the recursive call, and that call returns the updated value, you should not add that to the original size you already passed to it. By doing that, you have double counting. You should either just assign it back to your variable (not adding to it), or (better), not pass the current count as argument, but let each recursive call start counting from 0.

Here is a correction keeping the existing current_size parameter:

    def size(self) -> int:
        if self._root is None:
            return 0
        else:
            return self._sizerecur(0, self._root) # don't pass self as arg

    # A distinct name for this method
    def _sizerecur(self, current_size, current_node):
        if current_node:
            current_size += 1
        if current_node.left:
            # don't ADD again to current size
            current_size = self._sizerecur(current_size, current_node.left)
        if current_node.right:
            current_size = self._sizerecur(current_size, current_node.right)

        return current_size

But as said, it is better practice to implement this recursive function without current_size parameter. Instead of updating the counter while you recur deeper, update it while getting out of recursion:

    def size(self) -> int:
        if self._root is None:
            return 0
        else:
            return self._sizerecur(self._root)

    def _sizerecur(self, current_node):
        current_size = 0
        if current_node:
            current_size = 1
            if current_node.left:
                current_size += self._sizerecur(current_node.left)
            if current_node.right:
                current_size += self._sizerecur(current_node.right)
        return current_size

带有辅助功能的Python递归功能

还在原地等你 2025-02-08 03:31:51

对我来说,这是Firefox版本问题。我在Ubuntu 22.04上跑步,问题是Firefox的快照包。解决方案是完全卸载Firefox并从焦油文件中安装必要的版本,甚至APT-GEG都使用SNAP安装。更详细的信息在这里

For me, it was a firefox version issue. I was running on Ubuntu 22.04 and the issue was with the snap package of firefox. The solution was to uninstall firefox completely and install the necessary version from the tar file, even apt-get was using snap to install. More detailed info here.

“未能阅读木偶港口”运行硒&#x2B; geckodriver&#x2b; Firefox是Docker容器中的非根用户

还在原地等你 2025-02-08 00:36:37

要包括图片,您无法使用本地路径。您需要使用 asset_img_url 媒体过滤器。
因此您的代码应该看起来像

<img class="hacken" src="{{'tick.png' | asset_img_url: 'original'}}" width="20" height="20" loading="lazy"/>

To include pictures you cannot use a local path. You need to use the asset_img_url media filter.
So your code should look like

<img class="hacken" src="{{'tick.png' | asset_img_url: 'original'}}" width="20" height="20" loading="lazy"/>

如何在Shopify源代码中实现图像?

还在原地等你 2025-02-07 12:43:43

我不确定解决此问题的正确方法是什么,因为我也面临着同样的方法。但是到目前为止,我发现的是,可能会有一种解决这个问题的方法。

查看有关“ 禁用命令”,读取“模式”的文档,并注意CSS类” ck-disabled

如果/我找到了一种工作方式,我将尝试回到这里并发布更好的解决方案


更新:
当我发现我在my_plugin_ui.js中缺少代码部分时,我为我解决了这个问题。

  const command = editor.commands.get('nameOfCommand');

  // Execute the command when the button is clicked (executed).
  buttonView.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');

Im not sure what the correct method to resolve this is, as I also am facing the same. But what I have found so far, is that there might be a hacky way to get around this.

Checkout the docs regarding "disabling commands", "read-only" mode, and notice the CSS class "ck-disabled"

if/when I find a working way, I will try to come back here and post a better solution


Update:
I fixed this for me when I found that I was missing the section of the code in my my_plugin_ui.js where

  const command = editor.commands.get('nameOfCommand');

  // Execute the command when the button is clicked (executed).
  buttonView.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');

ckeditor 5在读取模式下未禁用自定义插件

还在原地等你 2025-02-07 12:14:10

您需要在可以访问您的专用网络的机器上运行代理。
通常,这可以通过使用自托管代理(安装在VM,VMS或容器实例上)来实现。

如果使用Azure DevOps,则可以从组织设置中添加新池。

默认的Azure代理使用公共访问权限,并且将无法使用仅限于专用网络的访问权限访问存储帐户。

您可能会发现在这里

You need to run agent on machine that has access to your private network.
Usually this can be achieved by using self-hosted agents (installed on VM, VMSS or on container instance) with access to your private network.

If you use Azure DevOps you may add new pool from organization settings.

Default Azure agents use public access and won't be able to access storage account with access limited only to private network.

More details you may find here

使用Azure DevOps管道复制数据到没有公共网络经验的存储帐户

还在原地等你 2025-02-07 01:52:09

错误清楚地告诉了发生了什么事

typeError:无法读取未定义的

的属性'findcustomer'

错误均值 abysionserationservice 是未定义的,并且您正在调用 findcustomer in undefined。

这里

让组织服务:组织服务;

您创建一个未定义的变量。您需要先初始化它。

如果您内部有任何依赖性 anduransionsVice ,则需要注入该类对象。如果不只是 new Ansuranationservice()将起作用

The error tells clearly what exactly happening

TypeError: Cannot read property 'findCustomer' of undefined

The error means organizationService is undefined and you are calling findCustomer on undefined.

Here

let organizationService: OrganizationService;

you create an undefined variable. you need to initialize it first.

If you have any dependency inside OrganizationService then you need to inject that class object. if not just new OrganizationService() will work

将服务添加到自定义路线装饰器Nestjs

还在原地等你 2025-02-06 15:31:11

感谢您很好地提供示例输入。这是一种首先将桌子融化为长形式的方法,然后终止一个集体比以每月的平均年龄,然后在所有月份获得平均年龄。我认为,更多的月和几年列

#melt the wide table into a long table
long_df = df.melt(
    id_vars=['c','z'],
    var_name='date',
    value_name='val',
)

#extract the year and month from the date column
long_df[['year','month']] = long_df['date'].str.split('-', expand=True)
long_df['year'] = long_df['year'].astype(int)
long_df['month'] = long_df['month'].astype(int)

#group by c/z/month and shift to get avg yoy for each month
avg_month_yoy = long_df.groupby(['c','z','month'])['val'].apply(
    lambda v: v.sub(v.shift(1)).div(v.shift(1)).multiply(100).mean()
).reset_index()

#group by just c/z to get avg yoy over all months
avg_yoy = avg_month_yoy.groupby(['c','z'])['val'].mean()

#Add the avg_yoy back into the original table
df = df.set_index(['c','z'])
df['Avg_YoY_pct'] = avg_yoy
df = df.reset_index()

print(df)

输出

Thanks for providing example input so nicely. Here's an approach that first melts the table into long form and then permforms a groupby to get average YoY for each month, and then another groupby to get average YoY over all months. I think it is flexible to more months and years columns

#melt the wide table into a long table
long_df = df.melt(
    id_vars=['c','z'],
    var_name='date',
    value_name='val',
)

#extract the year and month from the date column
long_df[['year','month']] = long_df['date'].str.split('-', expand=True)
long_df['year'] = long_df['year'].astype(int)
long_df['month'] = long_df['month'].astype(int)

#group by c/z/month and shift to get avg yoy for each month
avg_month_yoy = long_df.groupby(['c','z','month'])['val'].apply(
    lambda v: v.sub(v.shift(1)).div(v.shift(1)).multiply(100).mean()
).reset_index()

#group by just c/z to get avg yoy over all months
avg_yoy = avg_month_yoy.groupby(['c','z'])['val'].mean()

#Add the avg_yoy back into the original table
df = df.set_index(['c','z'])
df['Avg_YoY_pct'] = avg_yoy
df = df.reset_index()

print(df)

Output

enter image description here

计算平均Yoy百分比变化-pandas DataFrame

还在原地等你 2025-02-06 14:15:40

因此,首先我们需要了解一些术语。您比较Windows终端和 cmd.exe ,但实际上是两个完全不同的应用程序类型。 CMD是旧的Windows shell 。它在A 终端模拟器(又称终端)内运行。它可以在Windows中运行多个终端:

  • 默认情况下,Windows 10中,它在Legacy Windows控制台主机中运行。这是Windows的近30年(也许更可能)旧终端。
  • CMD还可以在Microsoft的 Windows终端内运行,可在Windows 10或Windows 11中安装。在Windows 11下,它可以成为Windows的默认终端。

当您要求Windows运行控制台/终端应用程序(例如Python CLI应用程序)时,Windows总是在默认终端运行它 - 在Windows 10下,始终是Windows Console Host。在Windows 11下,它可以是Windows控制台主机或Windows终端,具体取决于用户配置。

但是,还有其他多个终端可以在Windows中运行您的CLI Python应用程序:

一些更受欢迎的终端是:

  • CONEMU
  • CMDER
  • MOBAXTERM

您可以在此博客文章

因此,您的应用程序实际上不是在CMD中运行在Windows控制台主机(默认终端仿真器)下。

请注意,python也可以在其他外壳(PowerShell,WSL下的Linux shell,Nushell等)下运行。这些壳也可以在上面的任何端子中运行。或者您的Python CLI应用程序可以作为终端内部的顶级运行。

好的,现在我们已经建立了一些基础知识...

但是我想要一个更精细的GUI,例如Windows终端。

有点不清楚您的意思,但是除了试图打包Windows终端外,还有其他解决方案。传统控制台和Windows终端都应具有类似的功能 。 Windows Terminal添加了用户的标签之类的内容,但是您在应用程序中无法控制它。控制台主机和WT都可以使用相同的Windows字体配置。

您在Windows终端中执行的一件事是您无法在控制台主机中执行的一件事是为您的应用程序定义A profile ,包括主题,背景图像等。它在下面运行。也许这就是您的要求,但是您没有指定这些功能。

建议进行GUI

的任何方法

如果您想在Python创建GUI, 框架而不是作为CLI应用程序。您甚至可以在Python中编写终端模拟器,但这可能有点过分杀伤。

或一种用我的python程序将Windows终端捆绑的方法。

这可能不是一个好主意。 Windows Terminal将其安装为Microsoft Store应用程序(又称UWP,Modern等)时,最有效。不可能将Microsoft Store应用程序与另一个应用程序捆绑在一起;就像您无法从iOS上的另一个Apple App Store应用程序自动安装另一个Apple App Store应用程序一样。也可以以传统的 .exe 来安装/运行Windows终端,但这不是默认(或支持)方式。

您可以考虑以下内容:

So first we need to understand some terminology. You compare Windows Terminal and cmd.exe, but those are actually two entirely different types of applications. CMD is the old Windows shell. It runs inside a terminal emulator (a.k.a. terminal). There are multiple terminals that it can run under in Windows:

  • By default in Windows 10, it runs in the legacy Windows Console Host. This is the nearly 30 year (maybe more) old terminal for Windows.
  • CMD can also run inside Windows Terminal, the replacement terminal by Microsoft that is available to install in Windows 10 or Windows 11. Under Windows 11, it can become the default terminal for Windows.

When you ask Windows to run a console/terminal app, like your Python CLI app, Windows always runs it in its default terminal -- Under Windows 10, that is always the Windows Console Host. Under Windows 11, it may be either Windows Console Host or Windows Terminal, depending on the user configuration.

But there are also multiple other terminals that can run your CLI Python app in Windows:

Some of the more popular are:

  • ConEmu
  • Cmder
  • MobaXterm

You can find others listed in this blog post.

So it's really not that your app runs in CMD, but that your app runs in Python (the interpreter), which is running under CMD (the shell), which is running under Windows Console Host (the default terminal emulator).

Note that Python can also run under other shells (PowerShell, Linux shells under WSL, Nushell, etc.). These shells can also run in any of the terminals above. Or your Python CLI app can run as the top-level inside a terminal.

Ok, now that we've established some basics ...

But I would like a finer GUI, like that of Windows Terminal.

It's a bit unclear what you mean by that, but there may be other solutions than trying to package Windows Terminal. Both the legacy Console and Windows Terminal should have similar capabilities for your application. Windows Terminal adds things like tabs for the user, but you won't have control over that in your application. Both Console Host and WT can be configured with the same Windows fonts.

One thing you can do in Windows Terminal that you can't in Console Host is define a Profile for your application, including the themes, background image, etc. that you want it to run under. Perhaps that's what you are asking for, but you don't specify that those capabilities.

suggest any methods to make the GUI

If you are looking to create a GUI in Python, consider building it using a GUI Framework rather than as a CLI application. You can even write a terminal emulator in Python, but that would likely be a bit overkill for this.

or a method to bundle up Windows Terminal with my Python program.

That's probably not a good idea. Windows Terminal works best when it is installed as a Microsoft Store app (a.k.a. UWP, Modern, etc.). It is not possible to bundle Microsoft Store apps with another application; just like you can't install another Apple App Store app automatically from another on iOS. It's also possible to install/run Windows Terminal as a traditional .exe, but that's not the default (or supported) way.

You might consider the following:

  • Have your main Python app be a "launcher" that checks to see if Windows Terminal is installed, perhaps by looking for the existing of the wt.exe.

  • If Windows Terminal is installed:

    • Check for the existence of your applications JSON fragment in the appropriate directory (see link). Install it if it doesn't exist.
    • Launch your application by calling something like wt.exe new-tab --profile <your_app_profile> to start or open a new tab in Windows Terminal with the profile you defined in your JSON fragment.
  • If Windows Terminal is not installed:

    • Recommend that the user install it. Open the Microsoft Store link to it.
    • If they choose not to, your launcher should still launch the CLI portion of the app -- Windows will use the default terminal, which should be Windows Console Host.
  • Provide the instructions for running the CLI portion by itself (without the launcher) so that users of other terminal emulators can run it inside their preferred environment.

如何在Python中为命令行应用程序制作GUI?

还在原地等你 2025-02-06 11:52:18

您描述的方式,必须将逗号分隔的值分为行。

我不确定您的意思是说某人的房间编号真的可以是 1234,5678 ,但是 - 您可能会这样做;这就是联合所有查询的一部分。

select *
from students s
where s.room_number in (-- split string into rows, i.e. separate '1234,5678' to
                        -- '1234' and '5678'
                        select regexp_substr(t.string, '[^,]+', 1, column_value)
                        from other_table t cross join
                          table(cast(multiset(select level from dual
                                              connect by level <= regexp_count(t.string, ',') + 1
                                             ) as sys.odcinumberlist))
                        union all
                        -- this is a value you have in that other table "as is" 
                        -- (i.e. '1234,5678')
                        select t.string
                        from other_table t                                             
                       );
                        

The way you described it, you'll have to split comma-separated values into rows.

I'm not sure what you mean by saying that someone's room number can really be 1234,5678 but hey - you probably do; that's what the UNION ALL part of the query does.

select *
from students s
where s.room_number in (-- split string into rows, i.e. separate '1234,5678' to
                        -- '1234' and '5678'
                        select regexp_substr(t.string, '[^,]+', 1, column_value)
                        from other_table t cross join
                          table(cast(multiset(select level from dual
                                              connect by level <= regexp_count(t.string, ',') + 1
                                             ) as sys.odcinumberlist))
                        union all
                        -- this is a value you have in that other table "as is" 
                        -- (i.e. '1234,5678')
                        select t.string
                        from other_table t                                             
                       );
                        

如何在甲骨文中分开的两个字符串之间做事

还在原地等你 2025-02-06 09:22:33

您可以做这样的事情:

change xs ys = [v | vs <- transpose [xs, ys], v <- vs]

但是我不会。这是编写此功能的一种非常令人困惑的方法 - 无论如何,您并没有真正将手动递归转换为以这种方式理解列表,您只是将手动递归推入 transpose

You could do something like this:

change xs ys = [v | vs <- transpose [xs, ys], v <- vs]

But I wouldn't. That's a very confusing way to write this function -- and anyway, you haven't really converted manual recursion into a list comprehension this way, you've just shoved the manual recursion into transpose.

如何将此递归功能变成列表理解?

还在原地等你 2025-02-06 06:01:25

当您收到的错误消息仅列出一个搜索路径时,JNA实际上检查了您的库的多个位置。如

搜索给定库将扫描以下位置:

  1. jna.library.path 用户可定制路径
  2. jna.platform.library.path 平台特定路径
  3. 在OSX上,〜/library/Frameworks /library/Frameworks /system/library/frameworks 将被搜索带有框架
    名称与所请求的相对应。框架的绝对路径是
    也接受了,要么以框架名称结尾(sans“ .framework”)
    或框架共享库的完整路径(例如
    coreservices.framework/coreservices)。
  4. 上下文类加载程序类路径。可以在 $ {os-prefix}/library_filename 的基础路径上安装部署的本机库
    其中 $ {OS-PREFIX} 是OS/ARCH前缀返回的
    platform.getNativelibraryResourceprefix()。如果捆绑在罐子文件中,
    该资源将提取到 jna.tmpdir 用于加载,然后再提取
    删除(但仅当 jna.nounpack 是false或不设置时)。

您可以设置系统属性 jna.debug_load = true 制作JNA
将其库搜索的步骤打印到控制台。

请注意上面项目4中的 OS-PREFIX 目录。您已将库直接包含在classPath(从注释,/users/username/downloads/testjna/src/src/main/java/test.dylib )上包含。但是,正如错误消息所述,它需要在您的classPath上的 darwin-x86-64/目录中,例如,/users/username/downloads/testjna/src/main// java/darwin-x86-64/test.dylib ;

您可能希望使用 src/main/resources 优先使用 java 非Java代码的子目录。

您将系统库路径设置为原始源代码目录的尝试不适用于在 target/class/class 目录结构中查看的编译代码。

请注意,您可以通过设置系统属性 jna.debug_load = true 来获取进一步的调试信息。

While the error message you received only lists one search path, JNA actually checks multiple locations for your library. As documented in the NativeLibrary class javadocs:

A search for a given library will scan the following locations:

  1. jna.library.path User-customizable path
  2. jna.platform.library.path Platform-specific paths
  3. On OSX, ~/Library/Frameworks, /Library/Frameworks, and /System/Library/Frameworks will be searched for a framework with a
    name corresponding to that requested. Absolute paths to frameworks are
    also accepted, either ending at the framework name (sans ".framework")
    or the full path to the framework shared library (e.g.
    CoreServices.framework/CoreServices).
  4. Context class loader classpath. Deployed native libraries may be installed on the classpath under ${os-prefix}/LIBRARY_FILENAME,
    where ${os-prefix} is the OS/Arch prefix returned by
    Platform.getNativeLibraryResourcePrefix(). If bundled in a jar file,
    the resource will be extracted to jna.tmpdir for loading, and later
    removed (but only if jna.nounpack is false or not set).

You may set the system property jna.debug_load=true to make JNA
print the steps of its library search to the console.

Note the os-prefix directory in item 4 above. You have included your library directly on the classpath (from the comments, /Users/username/Downloads/TestJNA/src/main/java/test.dylib). However, as the error message states, it needs to be in the darwin-x86-64/ directory on your classpath, e.g., /Users/username/Downloads/TestJNA/src/main/java/darwin-x86-64/test.dylib;

You may wish to use src/main/resources in preference to the java subdirectory for non-java code.

Your attempt to set the system library path to your raw source code directory doesn't work for the compiled code where it is looking in the target/classes directory structure.

Note that you can get further debugging information by setting the system property jna.debug_load=true.

无法在Maven项目中加载库

还在原地等你 2025-02-05 06:38:37

尝试:

=REGEXMATCH(B2&"", "^"&TEXTJOIN("$|^", 1, 
 FILTER(INDIRECT("Sheet2!A2:A"), INDIRECT("Sheet2!E2:E")<>""))&"$")

try:

=REGEXMATCH(B2&"", "^"&TEXTJOIN("$|^", 1, 
 FILTER(INDIRECT("Sheet2!A2:A"), INDIRECT("Sheet2!E2:E")<>""))&"
quot;)

enter image description here

Google表:查找匹配项,在相邻单元格中检查与匹配单元格的文本

更多

推荐作者

佚名

文章 0 评论 0

今天

文章 0 评论 0

゛时过境迁

文章 0 评论 0

达拉崩吧

文章 0 评论 0

呆萌少年

文章 0 评论 0

孤者何惧

文章 0 评论 0

更多

友情链接

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