仅一夜美梦

文章 评论 浏览 27

仅一夜美梦 2025-02-20 19:48:10

不,他们不会。

df ['id']。重复()返回一系列布尔值,具体取决于是否复制了ID。

df [df.duplicated('id')] 返回一个过滤的数据框架,其中只保留了复制ID的行。

例子:

df
  id  col
0  A    0
1  A    1
2  B    2
3  C    3
4  C    4
5  C    5

df['id'].duplicated()
0    False
1     True
2    False
3    False
4     True
5     True

df[df.duplicated('id')]
Name: id, dtype: bool
  id  col
1  A    1
4  C    4
5  C    5

No they won't.

df['id'].duplicated() returns a Series of booleans depending on whether the IDs are duplicated.

df[df.duplicated('id')] returns a filtered DataFrame where only the rows are kept in which the IDs are duplicated.

Example:

df
  id  col
0  A    0
1  A    1
2  B    2
3  C    3
4  C    4
5  C    5

df['id'].duplicated()
0    False
1     True
2    False
3    False
4     True
5     True

df[df.duplicated('id')]
Name: id, dtype: bool
  id  col
1  A    1
4  C    4
5  C    5

df [' id']。重复()和df [df.duplicated(' id')]有什么区别

仅一夜美梦 2025-02-20 15:03:38
SELECT city, phone FROM buildings ORDER BY city ASC, phone DESC

那样简单。看到它实时工作在这里

SELECT city, phone FROM buildings ORDER BY city ASC, phone DESC

as simple as that. See it working live here

MySQL订单由2列有条件

仅一夜美梦 2025-02-20 09:55:18

之所以不断发生的原因是因为您的功能

const handlecart=(item)=>{
    setCount(count+1)
    setItem(item)
}

正在触发此组件的重新渲染,因此为什么您看到它无限增加。例如,每次您通过增加设置 count +1时,您实际上是在告诉React,因为 count 已更改,请重新渲染并向我展示新的组件。

我怀疑您正在寻找的是 usecallback

const handleCart = useCallback(() => {
   setCount(count => count + 1)
   ...
}, [setCount])

The reason this keeps happening is because your function

const handlecart=(item)=>{
    setCount(count+1)
    setItem(item)
}

Is triggering a re-render of this component hence why you're seeing it increase infinitely. For example, each time you set the count by incrementing it +1, you're essentially telling React that since count has changed please re-render and show me the new component.

I suspect what you're looking for is useCallback

const handleCart = useCallback(() => {
   setCount(count => count + 1)
   ...
}, [setCount])

如何在React中修复此无限循环

仅一夜美梦 2025-02-20 02:50:03

package.json 中指定的所有依赖项都将包含在您在同一文件夹中创建的每个函数中。 firebase仅依赖于您部署的内容,例如nodejs,它以 npm 为其软件包管理器。最小化对其他功能的未使用依赖的唯一方法是在项目上具有目录结构,并在每个文件夹上具有多个 package.json

您还可以检查我对此的答案 thread package.json.json 有效。

All dependencies specified in the package.json will be included in each function you create inside the same folder. Firebase only relies on what you deploy on which for example is NodeJS which has npm as its package manager. The only way to minimize inclusion of unused dependencies on other functions is to have a directory structure on your project and have multiple package.json on each folder.

You could also check my answer on this thread which explains how package.json works.

部署具有不同依赖性的firebase功能

仅一夜美梦 2025-02-20 02:08:33

我认为您可以做的是将SiteMap.txt文件放入您的公共文件夹和路由器中 - > index.js

{ path: "/sitemap.txt"}

What I think you can do is to put the sitemap.txt file in your public folder and in your router --> index.js

{ path: "/sitemap.txt"}

如何将.txt文件添加到VUE单页应用程序中?

仅一夜美梦 2025-02-19 23:11:27

尝试:

self.startDate = datetime.datetime.now

问题是您已经在定义中调用该功能,然后您再次调用它。

如果您想要的是在实例化时设置开始日期,请让第一部分(如您发布)并尝试:

print("Started trading system, date: {}".format(ts.startDate))

第一个选项将始终打印当前日期和时间,前者将打印日期和实例化时间。

Try with:

self.startDate = datetime.datetime.now

The problem is that you are already calling the function within your definition and then you're calling it again.

If what you want is to set the start date at the time of instantiation, let the first part as it was (as you posted it) and try:

print("Started trading system, date: {}".format(ts.startDate))

The first option will always print the current date and time, the former will print the date and time of instantiation.

如何修复Python typeError:' datetime.datetime'对象不可呼出?

仅一夜美梦 2025-02-19 18:51:58

好的,显然是(自v3.8)非常简单:

在DLL搜索路径上添加路径。

解决导入的依赖关系时使用此搜索路径
扩展模块(模块本身通过SYS.Path解决),
也由ctypes。

Ok, apparently it's (since V3.8) very simple:

os.add_dll_directory:

Add a path to the DLL search path.

This search path is used when resolving dependencies for imported
extension modules (the module itself is resolved through sys.path),
and also by ctypes.

如何在运行时指定PYD DLL依赖关系搜索路径使用Python

仅一夜美梦 2025-02-19 14:38:36

仅使用一个循环,一个构建数据的循环,同时为每个类别增量计数器

ages = []
kids, teen, adult = 0, 0, 0

for i in range(10):
    age = int(input("Write your age"))
    ages.append(age)

    if age < 12:
        kids += 1
    elif age <= 17:
        teen += 1
    else:
        adult += 1

print("The number of kids is: ", kids)
print("The number of teenagers is: ", teen)
print("The number of adults is: ", adult)

Use only one loop, the one that builds the data, at the same time increment counter for each category

ages = []
kids, teen, adult = 0, 0, 0

for i in range(10):
    age = int(input("Write your age"))
    ages.append(age)

    if age < 12:
        kids += 1
    elif age <= 17:
        teen += 1
    else:
        adult += 1

print("The number of kids is: ", kids)
print("The number of teenagers is: ", teen)
print("The number of adults is: ", adult)

在附加列表(用户输入)(Python)中计数和分离年龄

仅一夜美梦 2025-02-19 09:33:50

Pro的

  1. 行为定义得很好;静态缓冲区在程序的持续时间内存在,并且在 filter_something 返回后,程序可以使用。

cons

  1. 返回静态缓冲区很容易出错,因为为例程编写电话的人们可能会忽略或不知道返回静态缓冲区。这可能会导致尝试使用从多个调用到该函数的多个缓冲区的实例(在同一线程或不同的线程中)。清晰的文档是必不可少的。

  2. 静态缓冲区在程序的持续时间内存在,因此它在不需要的时候占据空间。

Pro

  1. The behavior is well defined; the static buffer exists for the duration of the program and may be used by the program after filter_something returns.

Cons

  1. Returning a static buffer is prone to error because people writing calls to the routines may neglect or be unaware that a static buffer is returned. This can lead to attempts to use multiple instances of the buffer from multiple calls to the function (in the same thread or different threads). Clear documentation is essential.

  2. The static buffer exists for the duration of the program, so it occupies space at times when it may not be needed.

将指针返回静态缓冲区

仅一夜美梦 2025-02-19 04:59:33

在“结果”选项卡中添加一行,然后在字段列下选择公式(文本)。在“公式”列中添加:

CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} ELSE {custbody_listing_agent} END

您需要将括号中的字段 {} 替换为您使用的字段的正确ID。我以为这些字段都从相同的记录列表(联系人或客户)中获取它们所包含的信息。例如,如果一个是选择(列表/记录)字段,而其他可能是免费的文本,则可能无法正常工作。这只会将业务源字段与(任意)上市代理(任意)比较销售代理,如果有匹配,则将其返回销售代理,否则返回了清单代理。请注意,这意味着在任何其他情况下也将退还上市代理;例如,如果比较字段之一为空。

您可以明确地将业务源与两个代理字段匹配,并在不匹配案例语句时略微返回其他值时:

CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} WHEN {custbody_business_source} = {custbody_selling_agent} THEN {custbody_listing_agent} ELSE {somethingelse} END

或使用 decode 而不是:

DECODE({custbody_business_source}, {custbody_listing_agent}, {custbody_selling_agent}, {custbody_selling_agent}, {custbody_listing_agent}, {somethingelse})

decode 具有以下签名:

DECODE({expr}, search, result, [search, result]..., [default])

它将 expr 与每个 search 一个一个一个一个一个逐一比较。如果找到匹配项,它将返回相应的结果。如果找不到匹配,则返回默认值,或者如果未指定默认值,则null。

Add a line in the Results tab and select Formula (text) under the Field column. In the Formula column add:

CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} ELSE {custbody_listing_agent} END

You will need to replace the fields in braces {} with the correct IDs for the fields you're using. I have assumed that these fields all pull from the same list of records (contacts or customers) for the information they contain. It probably won't work, for example, if one is a select (List/Record) field and the others are Free Text. This simply compares the Business Source field with (arbitrarily) the Listing Agent and returns the Selling Agent if there's a match, otherwise it returns the Listing Agent. Note that this means the Listing Agent will be returned in any other circumstances also; for example if one of the compared fields is empty.

You could match the Business Source against both the agent fields explicitly and return some other value when neither match by extending the CASE statement a little:

CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} WHEN {custbody_business_source} = {custbody_selling_agent} THEN {custbody_listing_agent} ELSE {somethingelse} END

or by using a DECODE instead:

DECODE({custbody_business_source}, {custbody_listing_agent}, {custbody_selling_agent}, {custbody_selling_agent}, {custbody_listing_agent}, {somethingelse})

DECODE has the following signature:

DECODE({expr}, search, result, [search, result]..., [default])

It compares expr with each search value one by one. If it finds a match it returns the corresponding result. If no match is found, the default is returned, or null if default is not specified.

当一个字段不等于另一个字段时,则显示一个完全不同的字段

仅一夜美梦 2025-02-19 03:17:21

当前,在您的按钮函数中,您可以执行此操作:

onClick={() => [
      setDetails((currentDetails) => !currentDetails),
      setArticleId(article.id),
]}

第一行切换细节是否可见。当前所有按钮都会切换详细信息可见性。您想要的是仅当它是与当前显示的详细信息相对应的按钮时。

onClick={() => {
      //If no details are visible, show them
      if(!details) setDetails(true);   
      //If details are visible, and this is the corresponding button, hide them
      else if(article.id == articleId) setDetails(false); 
      setArticleId(article.id);
}}

Currently, in your buttons onClick functions you do this:

onClick={() => [
      setDetails((currentDetails) => !currentDetails),
      setArticleId(article.id),
]}

The first line toggles whether or not the details secions is visible. All buttons currently toggle the details visibility. What you want is to only do this when it is the button corresponding to the currently displayed details.

onClick={() => {
      //If no details are visible, show them
      if(!details) setDetails(true);   
      //If details are visible, and this is the corresponding button, hide them
      else if(article.id == articleId) setDetails(false); 
      setArticleId(article.id);
}}

如何区分功能中的按钮和行为

仅一夜美梦 2025-02-18 23:23:05

大家,这是一个非常愚蠢的错误。如果(result.length&gt; 0)在我的后端代码中。所以应该像这样:

app.get("/:projectId/attachment", function(req, res){

    const projectId = req.params.projectId;

    try{
        const findProjectAttachment = "SELECT project_attachment.project_attachment_id, project_attachment.project_attachment_url, project_attachment.project_id FROM project_attachment INNER JOIN project ON project_attachment.project_id=project.project_id WHERE project_attachment.project_id = ?;";

        db.query(findProjectAttachment, projectId, (err, result) => {

                res.send(result);
            }
        )
    }
    catch(err){
        console.log(err);
    }
});

You all, it was a very silly mistake. I should not have included if(result.length > 0) in my back-end code. So it should have been like this:

app.get("/:projectId/attachment", function(req, res){

    const projectId = req.params.projectId;

    try{
        const findProjectAttachment = "SELECT project_attachment.project_attachment_id, project_attachment.project_attachment_url, project_attachment.project_id FROM project_attachment INNER JOIN project ON project_attachment.project_id=project.project_id WHERE project_attachment.project_id = ?;";

        db.query(findProjectAttachment, projectId, (err, result) => {

                res.send(result);
            }
        )
    }
    catch(err){
        console.log(err);
    }
});

React使用效应仅随文件上传而延迟

仅一夜美梦 2025-02-18 15:32:27

我不明白的是,为什么您要在textchanged上创建一个运行时的条目。每次您在条目中键入此文本变化事件的条目中,这将在输入后从字面上创建条目。

当您在此处创建一个新条目时,UI上的不是内容,如果您想在UI上输入以触发此内容,则必须给触发条目一个名称,然后使用该名称来检查该条目中的内容并更新因此。另外,您可以使用“发件人”对象。

您的XAML会像:

<Entry Grid.Row="0" Grid.Column="1" x:Name="EntryBoxBarCode" WidthRequest="250" TextChanged="EntryBoxBarCode_TextChanged"/>
<Entry Grid.Row="" Grid.Column="1" x:Name="EntryPackCode" WidthRequest="250" />


private void EntryBoxBarCode_TextChanged(object sender, TextChangedEventArgs e)
    {
        if (EntryBoxBarCode.Text != "")
        {
            WorkFormCheck(EntryBoxBarCode.Text);

            if (typeOfBarCode != "")
            {
                //Here is the condition where I want to clear the text
                EntryBoxBarCode.Text = "";
                //EntryBoxBarCode.Focus(); //not sure this is required or not since you should already have focus here.
            }
        }
        else
        {
            //passing the right value of the entry, then focus to other Entry
            EntryPackCode.Focus();
        }         
    }

What I don't understand is why are you creating an entry on runtime on TextChanged. This will literally create entry after entry every time you type a text in the entry that calls this Textchanged event.

When you are creating a new entry here it's not something that's on your UI, if you want an entry on your UI to trigger this you will have to give the triggering entry a name and then use that name to check what's in that entry and update accordingly. Alternatively, you could use the sender object.

Your XAML would be something like:

<Entry Grid.Row="0" Grid.Column="1" x:Name="EntryBoxBarCode" WidthRequest="250" TextChanged="EntryBoxBarCode_TextChanged"/>
<Entry Grid.Row="" Grid.Column="1" x:Name="EntryPackCode" WidthRequest="250" />


private void EntryBoxBarCode_TextChanged(object sender, TextChangedEventArgs e)
    {
        if (EntryBoxBarCode.Text != "")
        {
            WorkFormCheck(EntryBoxBarCode.Text);

            if (typeOfBarCode != "")
            {
                //Here is the condition where I want to clear the text
                EntryBoxBarCode.Text = "";
                //EntryBoxBarCode.Focus(); //not sure this is required or not since you should already have focus here.
            }
        }
        else
        {
            //passing the right value of the entry, then focus to other Entry
            EntryPackCode.Focus();
        }         
    }

清除条目。文本值如果感知某个条件

仅一夜美梦 2025-02-18 04:07:10

原来我设法解决了这个问题。

谁将其上次保存为ANSI,而不是UTF-8。

感谢您的指示,因为我想检查的不是何处。当我希望看到它实际上编码的内容时,我发现了这一点,以回应上面的评论。我以为是UTF-8,因为库中的所有其他文件都是UTF-8,实际上,此处的所有文件都是UTF-8,除了这个文件,现在...

现在可以稍微提高其Pylint评分。

Turns out I've managed to fix the problem.

Whoever edited it last saved it as ANSI rather than UTF-8.

Thanks for the pointers, as its not somethign I would have thought of checking. I found this out when I was looking to see what it was actually encoded as, in response to the comments above. I'd have assumed it was UTF-8 as all the other files in the library are UTF-8, in fact everything here is utf-8, apart from this one file...

Now to up its pylint score a bit.

幽门特错误或没有指定的编码

仅一夜美梦 2025-02-18 02:43:00

如果文件作为单独的Windows/Tabs保留,则文件编辑器将必须将每个选项卡缩小到最小的高度,然后垂直瓷砖。如果有任何编辑可以做到,我怀疑它将是emacs或vim。您也可以通过打开单独的编辑窗口并使用瓷砖窗口管理器来做到这一点。

我们可以通过一些文本编辑魔术实现类似的效果。它将像:

  • 在每个文件中添加一个标题,该文件由唯一的分隔符(例如#===魔术saparator === fileName my_file.js ====
  • 使用 cat 代码>要将所有文件组合到一个文件中
  • ,在完成后编辑此文件
  • ,请使用分隔符将其分解并将文本放回原始文件中,

您可以轻松地编写一些脚本进行组合和分配,以便您可以快速执行此操作。您还可以设置一个背景脚本,该脚本在编辑组合文件时自动运行分离器。但是,合并的文件本质上是一个新文件,因此您无法使用git查看其更改,而VS Code的Codelens/Inline责备将无效。

一种选择是将您的代码库与签入VC的组合文件一起开发代码库,然后仅将分离器脚本作为“构建”步骤的一部分。因此,您将进行更改,运行 ./ build.sh 将文件分解为某个临时目录,然后从那里运行您的应用程序。

最后,我讨厌打nide,但事实是,通过避免设计不考虑开发人员人体工程学的设计不佳的框架,最好解决此问题。许多其他语言为开发人员提供了很多自由和许多工具来组织其所需的代码,而不是施加限制,例如要求许多小型组件在单独的文件中。例如,Java也有类似的问题(如果最近的版本修复了它,则DUNNO) - 每个文件只能有一个类,如果您喜欢拥有许多小文件,这会产生巨大的混乱。 C#没有此限制,因此C#代码库可以比Java代码库更加整洁。

If the files stay as separate windows/tabs, the file editor would have to shrink each tab to a minimal height, and then tile them vertically. If any editor can do it, I suspect it would be emacs or vim. You might also be able to do it by opening separate editor windows and using a tiling window manager.

We can achieve a similar effect with some text editing magic. It would be something like:

  • Add a header to each file consisting of a unique separator (e.g. # === magic separator === filename my_file.js ===)
  • Use cat to combine all the files into one file
  • Edit this one file
  • When done, use the separator to break them up and put the text back into the original files

You could easily write some scripts for combining and splitting so you can do it quickly. You can also set up a background script that automatically runs the splitter as you edit the combined file. However, the combined file would essentially be a new file, so you could not view changes on it with git, and VS Code's CodeLens/Inline blame wouldn't work.

One option would be to develop your codebase with the combined files checked in to VCS, and then only have the splitter script as part of your "build" step. So you would make your changes, run ./build.sh which splits the files into some temp directory, and then run your application from there.

Lastly, and I hate to be snide, but the fact is that this problem is best solved by avoiding poorly designed frameworks that do not consider developer ergonomics. Many other languages give the developer much freedom and many tools to organize their code as they wish, rather than imposing constraints like requiring many small components to be in separate files. Java for example also had a similar problem (dunno if more recent versions fixed it) - you can only have one class per file, which creates a huge mess if you like having many small files. C# does not have this limitation and as a result C# codebases can be much tidier than Java codebases.

编辑文件好像是连接的一样 - 任何IDE或文本编辑器都具有此功能吗?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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