坏尐絯

文章 评论 浏览 608

坏尐絯 2025-02-21 01:06:31

preg_replace在此示例中有许多重要的角色,我使用此特殊的PHP函数来替换文本块内部的URL。

<?php

$plaintext = "https://www.stackoverflow.com<br/>";

echo url_to_clickable_link($plaintext);

function url_to_clickable_link($plaintext) {

  return preg_replace(
  '%(https?|ftp)://([-A-Z0-9-./_*?&;=#]+)%i', 
  '<a target="blank" rel="nofollow" href="$0" target="_blank">$0</a>', $plaintext);

}

?>

preg_replace has many important roles Here in this example, I have used this special PHP function to replace URL inside text block clickable.

<?php

$plaintext = "https://www.stackoverflow.com<br/>";

echo url_to_clickable_link($plaintext);

function url_to_clickable_link($plaintext) {

  return preg_replace(
  '%(https?|ftp)://([-A-Z0-9-./_*?&;=#]+)%i', 
  '<a target="blank" rel="nofollow" href="$0" target="_blank">$0</a>', $plaintext);

}

?>

将链接添加到页脚PHP文案文本

坏尐絯 2025-02-20 12:59:30

如果 self.fields 是空的怎么办?在这种情况下,根本不会执行循环。什么会返回?

通常,除 loop 没有 break 外,所有循环类型都不会影响该函数是否会返回,因为它们可能无法运行。

What if self.fields is empty? In this case, the loop won't be executed at all. What will be returned?

In general, all loop kinds except loop without break cannot affect whether the function will return, because they may not run.

期望U16返回类型错误的函数,即使我使用的返回以提早获得函数的值,但不匹配的类型不匹配

坏尐絯 2025-02-20 09:56:07

pybind11 中的指针功能参数不起作用。

所有“ Pointer-To-T”和“ Referent to To-T”函数参数均已转换,以使Python仅看到PLAINT。因此,如果您调用

x = 0.123
myFunc(x, 42)

Python,请看到一个接受两个 float 参数的函数,并且C ++实现在 *ptr = val 分配之前,请看到*ptr == 0.123

void myFunc(double* ptr, double value)
{
    std::cout << "Before:\t\t" << *ptr << std::endl;
    *ptr = value;
    std::cout << "After:\t\t" << *ptr << std::endl;
};

Before:   0.123
After:    42

C ++函数中的指针指向python x 对象(通常是不可能的,因为Python的 float 不一定与C ++'S double是相同的东西),但在呼叫期间由PYBIND11机械持有的C ++表示。对该C ++对象的修改不会传播回Python。

为了通过C ++和Python之间的指针,您需要将它们包裹在某种类中,以将其隐藏在PYBIND11机械中。

Pointer function parameters in pybind11 don't work this way.

All "pointer-to-T" and "reference-to-T" function parameters are transformed such that Python only sees plain T. So if you call

x = 0.123
myFunc(x, 42)

Python sees a function that accepts two float arguments, and the C++ implementation sees *ptr == 0.123 before *ptr = val assignment.

void myFunc(double* ptr, double value)
{
    std::cout << "Before:\t\t" << *ptr << std::endl;
    *ptr = value;
    std::cout << "After:\t\t" << *ptr << std::endl;
};

Before:   0.123
After:    42

The pointer in the C++ function points not to the Python x object (it would not be generally possible, because Python's float is not necessarily the same thing as C++'s double), but to its C++ representation held by pybind11 machinery for the duration of the call. Modifications to that C++ object are not propagated back to Python.

In order to pass pointers between C++ and Python, you need to wrap them in some sort of class that hides them from the pybind11 machinery.

pybind11指针参考

坏尐絯 2025-02-20 01:08:32

您是否有机会使用 - 强制标志尝试过相同的命令?这通常可以解决问题。

Did you by any chance tried the same command with the --force flag? This usually does the trick.

Angular Powered Bootstrap安装ERESOLVEL ERROR

坏尐絯 2025-02-19 15:17:40

我也有同样的问题
我更新了Gradle

classpath'com.android.tools.build:3.5.1'

classpath'com.android.tools.build:4.1.3'

它解决了问题

i had the same issue
i update gradle
from
classpath 'com.android.tools.build:gradle:3.5.1'
to
classpath 'com.android.tools.build:gradle:4.1.3'

it fixes the issue

请帮助:评估项目的问题发生了问题。 &gt;没有方法的签名

坏尐絯 2025-02-19 03:49:56

您可以这样做:

string1 = "Green | Green | Red | Orange | Blue | Cut | Yellow | Yellow"

split_text = string1.split("|")
Result = Array.from(new Set(split_text.map(x => x.trim()))).join('|')
//'Green|Red|Orange|Blue|Cut|Yellow'

You could do this:

string1 = "Green | Green | Red | Orange | Blue | Cut | Yellow | Yellow"

split_text = string1.split("|")
Result = Array.from(new Set(split_text.map(x => x.trim()))).join('|')
//'Green|Red|Orange|Blue|Cut|Yellow'

Java脚本结合字符串/数组

坏尐絯 2025-02-19 03:36:03

您的代码完全很好,您只是对C ++的 printf 功能感到困惑。

也许您有Python,JavaScript或其他脚本语言的经验,而印刷功能可以接受任何内容并很好地打印出来。像C ++这样的强大类型语言并非如此。

您应该阅读 printf上的文档

name s1_name = s1.get_name();
printf("%s %s\n", s1_name.firstName.c_str(), s1_name.lastName.c_str());

另外,您可以使用 std :: cout ,它将为您处理格式类型。

std::cout << s1_name.firstName << ' ' << s1_name.lastName  << '\n';

您还可以定义一种让 std :: cout 知道如何处理结构的方法:


struct name
{
    string firstName;
    string lastName;
    friend std::ostream& operator <<(ostream& os, const name& input)
    {
        os << input.firstName << ' ' << input.lastName << '\n';
        return os;
    }
};
...
std::cout << s1_name;

Your code is totally fine, you're just confused about the printf function of C++.

Maybe you have experience with python, javascript, or other scripting languages that the print function accepts anything and prints it out nicely. That is not the case with a strong typed language like C++.

You should read the docs on printf.

name s1_name = s1.get_name();
printf("%s %s\n", s1_name.firstName.c_str(), s1_name.lastName.c_str());

Alternatively, you could use std::cout, which will handle the format type for you.

std::cout << s1_name.firstName << ' ' << s1_name.lastName  << '\n';

You could also define a way to let std::cout know how to handle your struct:


struct name
{
    string firstName;
    string lastName;
    friend std::ostream& operator <<(ostream& os, const name& input)
    {
        os << input.firstName << ' ' << input.lastName << '\n';
        return os;
    }
};
...
std::cout << s1_name;

当Gthe struct在班级外声明时,如何在类中返回结构?

坏尐絯 2025-02-18 21:04:35

仔细看看第一张图片的左上角。

VSCODE提示您创建一个“启动”。我认为您在第一个调试过程中不会在工作区中创建“启动”。请按照提示。

Take a closer look at the upper left corner of your first picture.

Vscode prompted you to create a "launch.json". I don't think you created a "launch.json" in the workspace during your first debugging process. Please follow the prompts.

vscode&#x2b; pipenv&#x2B; WSL中的Pyenv:调试器不与Python合作仅用于非系统Python版本

坏尐絯 2025-02-18 08:36:31

如果您查看 simpledialog.dialog 类的源代码,您会发现 wait_window()是在对话框的末尾执行的。代码>试图像模态对话框一样制作窗口。

SO super().__ init __(...)内部 lankingialog .__ Int __()在关闭对话框之前不会返回。关闭对话框时, self.result 将重置为'en'。

您应该将行移动, self.result ='en'''' body()的开头(就像 self.selected_language ),然后删除 __ INIT __()函数。

以下是修改的代码:

import tkinter as tk
from tkinter.simpledialog import Dialog
from tkinter import ttk, LEFT, ACTIVE
from tkinter.ttk import Button, Frame

class LanguageDialog(Dialog):
    lang_dict = {
        'italiano': 'it',
        'español': 'es',
        'english': 'en',
        'galego': 'gl',
    }

    def _on_cmb_change(self, event):
        """
            Keeps updated the result variable with the code I want in the end
        """
        print(self.lang_dict[self.selected_language.get()])
        self.result = self.lang_dict[self.selected_language.get()]

    def body(self, master):
        self.selected_language = tk.StringVar()
        # initial self.result to 'en' here
        self.result = 'en'  # default value

        ops = tuple(self.lang_dict.keys())
        cmb_lang = ttk.Combobox(self, values=ops, state='readonly',
                                textvariable=self.selected_language)
        cmb_lang.pack(side=tk.TOP)

        cmb_lang.bind('<<ComboboxSelected>>', self._on_cmb_change)

    def buttonbox(self):
        """add standard button box.

        override if you do not want the standard buttons
        """

        box = Frame(self)

        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
        w.pack(side=LEFT, padx=5, pady=5)

        self.bind("<Return>", self.ok)

        box.pack()

if __name__ == '__main__':
    root = tk.Tk()
    root.withdraw() # hide the root window
    d = LanguageDialog(root)
    print(f'After the dialog, {d.result}')
    #root.mainloop() # don't need to call mainloop()

If you look into the source code of simpledialog.Dialog class, you will find that wait_window() is executed at the end of Dialog.__init__() which tries to make the window like a modal dialog.

So super().__init__(...) inside LanguageDialog.__init__() will not return until the dialog is closed. When the dialog is closed, self.result is reset to 'en'.

You should move the line, self.result = 'en' into the beginning of body() (just like self.selected_language) and then remove the __init__() function.

Below is the modified code:

import tkinter as tk
from tkinter.simpledialog import Dialog
from tkinter import ttk, LEFT, ACTIVE
from tkinter.ttk import Button, Frame

class LanguageDialog(Dialog):
    lang_dict = {
        'italiano': 'it',
        'español': 'es',
        'english': 'en',
        'galego': 'gl',
    }

    def _on_cmb_change(self, event):
        """
            Keeps updated the result variable with the code I want in the end
        """
        print(self.lang_dict[self.selected_language.get()])
        self.result = self.lang_dict[self.selected_language.get()]

    def body(self, master):
        self.selected_language = tk.StringVar()
        # initial self.result to 'en' here
        self.result = 'en'  # default value

        ops = tuple(self.lang_dict.keys())
        cmb_lang = ttk.Combobox(self, values=ops, state='readonly',
                                textvariable=self.selected_language)
        cmb_lang.pack(side=tk.TOP)

        cmb_lang.bind('<<ComboboxSelected>>', self._on_cmb_change)

    def buttonbox(self):
        """add standard button box.

        override if you do not want the standard buttons
        """

        box = Frame(self)

        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
        w.pack(side=LEFT, padx=5, pady=5)

        self.bind("<Return>", self.ok)

        box.pack()

if __name__ == '__main__':
    root = tk.Tk()
    root.withdraw() # hide the root window
    d = LanguageDialog(root)
    print(f'After the dialog, {d.result}')
    #root.mainloop() # don't need to call mainloop()

Python/tkinter:按对话框中的确定会破坏其中的信息

坏尐絯 2025-02-17 21:30:12

POD没有外部IP,因为节点负责与Internet进行通信。您可以检查此图以获取更多详细信息[1]。

似乎您在这里引用的是POD可以使用的内部IP地址范围。

您可以通过导航到 &gt; kubernetes引擎&gt;

单击群集的名称,然后滚动到“网络”。它将向您显示“群集POD地址范围(默认)”。您可以检查此文档[2]以获取更多详细信息。

[1]

[2] https://cloud.google.com/kubernetes-engine/docs/concepts/network-overviewwiew#ip-allocation

Pods have no external IP as the nodes are responsible for communication with the Internet. You can check this diagram for more details[1].

It seems what you're referring here is the internal IP address range that the pods can use.

You can get this information by navigating to > Kubernetes Engine > Clusters.

Click the name of your cluster, then scroll to "Networking". It will show you the "Cluster pod address range (default)". You can check this documentation[2] for more details.

[1] https://cloud.google.com/kubernetes-engine/docs/concepts/network-overview#pods

[2] https://cloud.google.com/kubernetes-engine/docs/concepts/network-overview#ip-allocation

从Google Kubernates获取所有外部IP

坏尐絯 2025-02-17 16:09:11

在您发布的特定表上,

t = 0.5 * x + 0.105 * y -0.9167 * z

但是每个CPU都有不同的速度,因此每个用户的时间都不同,您将需要在用户的计算机上运行基准标准。

您似乎已经运行了3个基准。如果您有更多,那么您将拥有比未知数更多的方程

On the specific table you posted,

t = 0.5 * x + 0.105 * y -0.9167 * z

But each CPU has different speeds, so the time would be different for each user, and you will need to run a benchmark on the user's computer.

You appear to have run 3 benchmarks. If you have more, then you will have more equations than unknowns, so you would need to do a multivariate linear regression to get a relationship between x,y,z and time

如何使用Excel中包含的先前数据预测Python中的变量?

坏尐絯 2025-02-17 01:31:30

当工作表控制器具有中等速度时,您需要使用button1。尝试将LAREGENUNDIMMEDDETENTIDEFIER设置为介质而不是大型:

sheet.largestundimmeddetentientsixifier = .Medium

You want to have Button1 tappable when sheet controller has medium detent. Try setting largestUndimmedDetentIdentifier to medium instead of large:

sheet.largestUndimmedDetentIdentifier = .medium

可访问性 - 无法通过TAP选择模态视图后面的按钮

坏尐絯 2025-02-16 20:00:29

我也试图运行它,对我不起作用。看来 browser.page_source 没有时间更新。我认为最好像@data_sc一样使用显式等待。

PS在这里有效,但这不是最好的解决方案:

from time import sleep

driver.find_element(By.XPATH, '//*[@id="__next"]/div[2]/div/div[1]/div[1]').click()
sleep(1)
driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[3]/div[1]').click()

I tried to run it too, it doesn't work for me. It seems that somehow the browser.page_source does not have time to update. I think it's better to use explicit waits as @data_sc did.

P.S. Here it works, but it's not the best solution:

from time import sleep

driver.find_element(By.XPATH, '//*[@id="__next"]/div[2]/div/div[1]/div[1]').click()
sleep(1)
driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[3]/div[1]').click()

Inditly_wait不做工作python selenium

坏尐絯 2025-02-16 12:03:34

您可以使用 deleteone(deleteone() href =“ https://mongoosejs.com/docs/api.html#model_model-remove” rel =“ nofollow noreferrer”> remove()

// Account is our model
const foundAccount = await Account.findById(userId);
// Do something with found account
await foundAccount.deleteOne();
// or
// await foundAccount.remove();

You can use deleteOne() or remove():

// Account is our model
const foundAccount = await Account.findById(userId);
// Do something with found account
await foundAccount.deleteOne();
// or
// await foundAccount.remove();

删除已检索到的元素

坏尐絯 2025-02-16 02:59:46

问题在于,我错误地应用了成本函数的公式和计算权重的公式:

The issue is that i wrongly applied the formula of the cost function and the formula for calculating the weights:

????=−1/????×(????????⋅????????????(????)+(1−????)????⋅????????????(1−????))

????=????−????/????×(????????⋅(????−????))

The solution is:

 J =  (-1/m) * (np.dot(y.T, np.log(h)) +  (np.dot((1-y).T, np.log(1-h)))
 theta = theta - (alpha/m) * gradient

python中的梯度下降函数 - 损失功能的错误或权重

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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