懵少女

文章 评论 浏览 31

懵少女 2025-02-20 23:17:16

等待在这里没有意义。

等待是管理承诺的工具。反过来,承诺是等待一次发生一次的工具。

valuechanges 发生每次价值变化,而不仅仅是一次。

如果您要把它包裹在承诺中,那么它将在第一次更改值时起作用,但是下次下一次会失败。


您应该使用 get 而不是或在订阅功能中进行工作,以便完成每个工作时间变化。

It doesn't make sense to await here.

await is a tool to manage Promises. Promises, in turn, are a tool to wait for something to happen once.

valueChanges happen every time the value changes, not just once.

If you were to wrap this in a promise, then it would work the first time the value changed, but then fail the next time it did.


You should either use get instead or do the work in the subscription function so it gets done each time the value changes.

您如何等待Firebase的数据?

懵少女 2025-02-20 11:36:01

当您建造解析器时,这种功能真的很棒。
考虑一下:

byte* buffer = ...;
if(*(int*)buffer == 'GET ')
  invoke_get_method(buffer+4);

此代码可能仅在特定的endianess上起作用,并且可能会破坏不同的编译器

This kind of feature is really good when you are building parsers.
Consider this:

byte* buffer = ...;
if(*(int*)buffer == 'GET ')
  invoke_get_method(buffer+4);

This code will likely only work on specific endianess and might break across different compilers

单引号在C++中有什么作用。当多个字符上使用时?

懵少女 2025-02-20 06:48:08

没关系。我的错误是,我仍在版本 3.72 上使用AWS提供商,而 v4.15.0 在此 Release版本链接

Nevermind. It's my mistake that I'm still using aws providers on version 3.72, while the serverlessv2 is just supported after v4.15.0 showed in this release version link

Terraform类型serverlessv2_scaling_configuration type

懵少女 2025-02-19 21:11:33

我不确定这是为什么,但是将等待时间从1000毫秒增加到1500,然后又回到1000。
我不确定,也许新的电子邮件只需要让婴儿一次发送多次发送。

I'm not sure why this is, but increasing the wait time from 1000 milliseconds to 1500, and then back to 1000 did the trick.
I'm not sure, maybe the new email just needed to get baby-stepped into sending multiple at a time.

5月30日更新后不可能从Gmail发送多个电子邮件

懵少女 2025-02-19 14:32:04

您可以使用Distnict()来做到这一点

.filter(Q(question__startswith='Who') | Q(question__startswith='What')).distnict()

You can do that using distnict()

.filter(Q(question__startswith='Who') | Q(question__startswith='What')).distnict()

如何将列表转换为多个Q对象?

懵少女 2025-02-19 10:34:29

使用“ nofollow noreferrer”>可选链接任何无效的链链参与者的未定义。

math.max()的打字稿定义是

max(...values: number[]): number;

undefined 不是有效的参数类型。

当未使用 endEdat 时,应默认为相关最早的值。 web/javascript/referent/operators/nullish_coalescing_operator“ rel =“ nofollow noreferrer”>无效合并操作员( ?? 。例如,

const defaultTime = Number.NEGATIVE_INFINITY;

const latest = Math.max(
  ...testList.map((test) => test.endedAt?.getTime() ?? defaultTime)
);

您还可以将 0 用作默认值,但是如果您的所有日期均为 1970-01-01 ,则可能会导致误报。

Using optional chaining results in undefined for any nullish chain participants.

The Typescript definition for Math.max() is

max(...values: number[]): number;

so undefined is not a valid argument type.

You should default to a relevant earliest value when endedAt is not defined using the nullish coalescing operator (??). For example

const defaultTime = Number.NEGATIVE_INFINITY;

const latest = Math.max(
  ...testList.map((test) => test.endedAt?.getTime() ?? defaultTime)
);

You could also use 0 as a default but that could lead to false positives if all your dates are pre 1970-01-01.

阵列地图方法可能不接受潜在的未定义参数

懵少女 2025-02-19 06:49:41

那应该解决这个问题。我相信第4行表示3,因为索引从0开始

df.loc[3] += df.loc[10]

That should do the trick. I believe row 4 means 3 since the index starts at 0

df.loc[3] += df.loc[10]

从熊猫中的特定索引开始,总和行在一起

懵少女 2025-02-19 05:32:18

您的代码有两个主要问题:

  1. 在执行时评估了lambdas内部的变量,因此 e 始终对应于循环中分配的最后一个 last 参考;
  2. 发出信号时,将其连接多次调用功能:每次创建菜单时,您都会再次连接信号;

根据情况,有很多方法可以实现所需的目标。以下是一些可能的选项:

比较触发 exec()返回的操作

qmenu.exec()始终返回已触发的操作,知道您可以将其进行比较并最终决定要做什么:

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)
        self.mains = [QAction('Remove row'), QAction('Split expense')]
        self.types = [QAction('Bills'), QAction('Vapors')]

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        main_menu = QMenu()
        for action in self.mains:
            main_menu.addAction(action)
            action.setEnabled(index.isValid())

        if index.column() == 1:
            type_menu = main_menu.addMenu('Update')
            type_menu.addActions(self.types)

        action = main_menu.exec(event.globalPos())
        if action in self.mains:
            if action == self.mains[0]:
                self.remove_row(index.row())
        elif action in self.types:
            self.update_type(index.row(), action)

    def remove_row(self, row):
        self.model().removeRow(row)

    def update_type(self, row, action):
        print(action)

使用 action.data()作为参数

qactions支持设置任意数据,因此我们可以将该数据设置为行。如果我们使用 action.tigred 信号,我们可以通过 self.sender() (返回发出信号的对象)。否则,我们可以使用 菜单。 /a>以将其触发为参数的动作调用目标函数。

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)
        self.mains = [QAction('Remove row'), QAction('Split expense')]
        self.mains[0].triggered.connect(self.remove_row)
        self.types = [QAction('Bills'), QAction('Vapors')]

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        main_menu = QMenu()
        for action in self.mains:
            main_menu.addAction(action)
            action.setEnabled(index.isValid())
            action.setData(index.row())
        if index.column() == 1:
            type_menu = main_menu.addMenu('Update')
            type_menu.triggered.connect(self.update_type)
            for action in self.types:
                type_menu.addAction(action)
                action.setData(index.row())

        main_menu.exec(event.globalPos())

    def remove_row(self):
        sender = self.sender()
        if isinstance(sender, QAction):
            row = sender.data()
            if row is not None:
                self.model().removeRow(row)

    def update_type(self, action):
        print(action, action.data())

所以,没有兰伯达?

lambdas肯定可以使用,但是考虑到上述内容,并且您的要求是使用 dynamic 参数,这可能很棘手。

您可以将其用于A 完全动态菜单(包括创建动作),否则您需要始终尝试 disconnect()信号,这可能很棘手:

  • 使用lambda作为目标插槽意味着您没有任何必须断开连接功能的引用;
  • 如果信号先前已连接到其他函数,则完全断开信号(使用通用 signal.disconnect())的连接可能不是一个好选择;

完全动态的菜单

上述解决方案是基于以下事实:在上下文菜单事件时已经存在操作。

这通常不是要求。实际上,QT 始终中的许多小部件及其动作创建一个全新的菜单。都是基于文本的小部件(qlineedit,qtextedit,甚至具有适当的文本交互标志的Qlabels)的情况:菜单是始终临时。

考虑到这一点,我们可以根据上述解释采取一种方法,但无需考虑“更改”或“恢复”以前的状态,数据或连接:菜单将在关闭后立即被破坏,以及其任何一项动作(由于它们是作为菜单的孩子创建的),因此Python和QT将负责释放不再需要的资源。

虽然这种连续的创建/破坏物体似乎似乎不是最佳的,记忆/性能明智,但实际上在概念上更好,相当有效:菜单通常不需要极端性能,而创建/破坏它们实际上比管理持续的行为更简单一组菜单/操作取决于上下文。

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        isValid = index.isValid()
        main_menu = QMenu()

        removeAction = main_menu.addAction('Remove row')
        if isValid:
            removeAction.triggered.connect(lambda:
                self.remove_row(index.row()))
        else:
            removeAction.setEnabled(False)

        splitAction = main_menu.addAction('Split expanse')
        if isValid:
            splitAction.triggered.connect(lambda:
                self.split_expanse(index.row()))
        else:
            splitAction.setEnabled(False)

        type_menu = main_menu.addMenu('Update')
        if index.column() != 1:
            type_menu.setEnabled(False)
        else:
            billsAction = type_menu.addAction('Bills')
            billsAction.triggered.connect(lambda:
                self.bills(index.row()))
            vaporsAction = type_menu.addAction('Vapors')
            vaporsAction.triggered.connect(lambda:
                self.doVapors(index.row()))

        main_menu.exec(event.globalPos())

进一步的选项

在某些情况下需要保留持久的动作或菜单,例如,一个菜单上有很多需要创建时间的项目。

如已经解释的那样,信号可以同时连接到多个功能(甚至相同的功能不止一次)。

Lambdas的问题是我们通常“排队”使用它们。这样做,我们始终失去对它们连接的引用:

    self.someAction.triggered.connect(lambda: self.whatever(xyz))

虽然我们只能使用通用 signal.disconnect(),它可以断开信号与任何函数或连接到的插槽的连接它可能不是一个可行的选择:也许信号也连接到了始终的其他函数,无论上下文不管动作)。这意味着我们不能明确地与上述使用的lambda断开连接。

幸运的是,众所周知,在python中,包括lambdas在内:

    doWhatever = lambda: self.whatever(xyz)
    self.someAction.triggered.connect(doWhatever)
    # ...
    menu.exec(pos)
    self.someAction.triggered.disconnect(doWhatever)

这样,我们确保我们仅在菜单事件的上下文中连接到动作,然后将其断开连接,无论已触发的实际操作。

请注意,上面的实际上与使用本地函数相同(从概念上讲,这是Lambdas的内容):

    def doWhatever():
        self.whatever(xyz)

    self.someAction.triggered.connect(doWhatever)
    # ...
    menu.exec(pos)
    self.someAction.triggered.disconnect(doWhatever)

上述方法的好处是,与简单的lambda相比,本地函数可以更容易地扩展。

结论

QACTION是一个奇怪的课程。它不是小部件,但可以用于此目的,它不需要父母,并且可以在许多对象(菜单,工具栏等)之间共享。与小部件相反,即使在同一UI中,也可以在许多地方出现一个动作:工具栏,梅纳巴尔,上下文菜单,qtoolbutton。

尽管如此,设置新操作的父母不会自动将操作添加到该操作的父列表中,因此 someobject.actions()不列出该操作,除非 addaction()< /代码>已被明确调用。

QT6从Qtwidgets到QTGUI的“迁移”使这些方面变得更加清晰,但仍然可以造成混乱。

由于其“抽象”性质(并考虑到上述方面),您可以以多种方式触发动作,如果开发人员清楚整个QACTION概念,则触发的动作可以以意外的方式调用连接的插槽。

了解所有这些非常重要,因为其“触发”的实施可能会发生巨大变化,并且对这些方面的认识是必须正确地实施其用法的意识。

例如,使用一个列表,该列表可能不是适当的选择,您可以考虑 QActionGroup 而不是(无论这些操作是否可检查或组是独家)。

There are two main problems with your code:

  1. variables inside lambdas are evaluated at execution, so e always corresponds to the last reference assigned in the loop;
  2. when a signal is emitted, functions are called as many times they have been connected: each time you create the menu, you're connecting the signal once again;

Depending on the situations, there are many ways to achieve what you need. Here are some possible options:

Compare the triggered action returned by exec()

QMenu.exec() always returns the action that has been triggered, knowing that you can just compare it and eventually decide what to do:

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)
        self.mains = [QAction('Remove row'), QAction('Split expense')]
        self.types = [QAction('Bills'), QAction('Vapors')]

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        main_menu = QMenu()
        for action in self.mains:
            main_menu.addAction(action)
            action.setEnabled(index.isValid())

        if index.column() == 1:
            type_menu = main_menu.addMenu('Update')
            type_menu.addActions(self.types)

        action = main_menu.exec(event.globalPos())
        if action in self.mains:
            if action == self.mains[0]:
                self.remove_row(index.row())
        elif action in self.types:
            self.update_type(index.row(), action)

    def remove_row(self, row):
        self.model().removeRow(row)

    def update_type(self, row, action):
        print(action)

Use the action.data() as argument

QActions supports setting arbitrary data, so we can set that data to the row. If we are using the action.triggered signal, we can retrieve the action through self.sender() (which returns the object that emitted the signal). Otherwise, we can use menu.triggered() to call the target function with the action that has triggered it as argument.

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)
        self.mains = [QAction('Remove row'), QAction('Split expense')]
        self.mains[0].triggered.connect(self.remove_row)
        self.types = [QAction('Bills'), QAction('Vapors')]

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        main_menu = QMenu()
        for action in self.mains:
            main_menu.addAction(action)
            action.setEnabled(index.isValid())
            action.setData(index.row())
        if index.column() == 1:
            type_menu = main_menu.addMenu('Update')
            type_menu.triggered.connect(self.update_type)
            for action in self.types:
                type_menu.addAction(action)
                action.setData(index.row())

        main_menu.exec(event.globalPos())

    def remove_row(self):
        sender = self.sender()
        if isinstance(sender, QAction):
            row = sender.data()
            if row is not None:
                self.model().removeRow(row)

    def update_type(self, action):
        print(action, action.data())

So, no lambda?

Lambdas can certainly be used, but considering what explained above, and that your requirement is to use dynamic arguments, that can be tricky.

You can use it for a fully dynamical menu (including creation of actions), otherwise you'd need to always try to disconnect() the signal, and that might be tricky:

  • using a lambda as target slot means that you don't have any previous reference to the function that has to be disconnected;
  • completely disconnecting the signal (using the generic signal.disconnect()) might not be a good choice, if the signal was previously connected to other functions;

A fully dynamical menu

The above solutions are based on the fact that the actions already existed at the time of the context menu event.

This is usually not a requirement. In fact, many widgets in Qt always create a brand new menu along with its actions. This is the case of all text-based widgets (QLineEdit, QTextEdit and even QLabels with the proper text interaction flags): the menu is always temporary.

With this in mind, we can take an approach based on what explained above, but without thinking about "changing" or "restoring" previous states, data or connections: the menu will be destroyed as soon as it's closed, along with any of its actions (since they've been created as children of the menu), so Python and Qt will take care of releasing resources that are not needed anymore.

While this continuous creation/destroy of objects might not seem optimal, memory/performance wise, it's actually conceptually better and quite effective: menus don't usually need extreme performance, and creating/destroying them is actually simpler than managing the behavior of a persistent set of menu/actions depending on the context.

class TableView(QTableView):
    def __init__(self, param):
        super().__init__()
        self.setModel(param.model)

    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        isValid = index.isValid()
        main_menu = QMenu()

        removeAction = main_menu.addAction('Remove row')
        if isValid:
            removeAction.triggered.connect(lambda:
                self.remove_row(index.row()))
        else:
            removeAction.setEnabled(False)

        splitAction = main_menu.addAction('Split expanse')
        if isValid:
            splitAction.triggered.connect(lambda:
                self.split_expanse(index.row()))
        else:
            splitAction.setEnabled(False)

        type_menu = main_menu.addMenu('Update')
        if index.column() != 1:
            type_menu.setEnabled(False)
        else:
            billsAction = type_menu.addAction('Bills')
            billsAction.triggered.connect(lambda:
                self.bills(index.row()))
            vaporsAction = type_menu.addAction('Vapors')
            vaporsAction.triggered.connect(lambda:
                self.doVapors(index.row()))

        main_menu.exec(event.globalPos())

Further options

There are occasions for which keeping persistent actions or menus is required, for instance a menu that has lots of items that require some amount of time to be created.

As already explained, signals can be connected to multiple functions at the same time (and even the same function more than once).

The issue with lambdas is that we usually use them "in line". Doing this, we always lose the reference to their connection:

    self.someAction.triggered.connect(lambda: self.whatever(xyz))

While we could just use the generic signal.disconnect(), which disconnects the signal from any function or slot connected to it, that might not be a viable option: maybe the signal is also connected to some other function that is always required to be triggered, no matter of the context (such as a visual hint about the activation of actions). This means that we cannot specifically disconnect from a lambda used as above.

Luckily, as we know, in Python "everything is an object", including lambdas:

    doWhatever = lambda: self.whatever(xyz)
    self.someAction.triggered.connect(doWhatever)
    # ...
    menu.exec(pos)
    self.someAction.triggered.disconnect(doWhatever)

In this way, we ensure that we only connect to the action in the context of the menu event, and disconnect it afterwards, no matter of the actual action that has been triggered.

Note that the above is actually the same as using a local function (which is what lambdas are, conceptually speaking):

    def doWhatever():
        self.whatever(xyz)

    self.someAction.triggered.connect(doWhatever)
    # ...
    menu.exec(pos)
    self.someAction.triggered.disconnect(doWhatever)

The benefit of the above approach is that a local function can be extended more easily than a simple lambda.

Conclusions

QAction is quite a strange class. It's not a widget, but it can be used for that purpose, it doesn't need a parent, and can be shared between many objects (menus, toolbars, etc.). As opposite to widgets, an action can appear in many places at the same time even in the same UI: a tool bar, a menubar, context menu, a QToolButton.

Nonetheless, setting the parent of a new action doesn't automatically add the action to that parent list of actions, so someObject.actions() won't list that action unless addAction() has been explicitly called.

The "migration" of Qt6 from QtWidgets to QtGui made these aspect partially more clear, but it can still create confusion.

Due to their "abstract" nature (and considering the above aspects), you can trigger an action in many ways, and a triggered action can call connected slots in unexpected ways if the whole QAction concept is clear to the developer.

It's extremely important to understand all that, as the implementation of their "triggering" might change dramatically, and awareness of those aspects is mandatory to properly implement their usage.

For instance, using a list that groups actions might not be the proper choice, and you may consider QActionGroup instead (no matter if the actions are checkable or the group is exclusive).

python pyqt6 contextmenuevent奇怪的行为我不理解

懵少女 2025-02-19 02:59:08

它是 filenotfoundException crurnerconverter.php 不存在(也许是错字错误?),或者不在与 index.php

我用 action =“#” 对您的表格进行了测试,以重定向到同一页面,并且它可以很好地工作,因此您的问题除了表格的操作之外没有任何东西...

此处如果您能够生成第一页并查看表格,则问题不能来自MAMP;)

It is a FileNotFoundException : currencyconverter.php doesn't exist (maybe a typo error ?) or is not in the same directory as index.php.

I tested your form with action="#" to redirect to the same page and it works perfectly, so your problem cannot be anything but the form's action...

enter image description here

The problem cannot come from MAMP if you are able to generate the first page and to see the form ;)

如何解决服务器上找不到的URL问题?

懵少女 2025-02-18 19:40:46

要充分利用流功能,您需要使用流,过滤和减少功能如下:

// Get the stream from entrySet
String result = map.entrySet().stream()    
      // Filter entries based on your condition
      .filter(val ->  val.getValue() >= 10 
                           && !Objects.equals(val.getKey(), " ") 
                           && val.getKey().length() > 3)  
       // Apply the reduce to combine filtered entries in a single string     
      .reduce("", (stats, val) -> stats 
                                  + val.getKey().toLowerCase() 
                                  + " - " 
                                  + val.getValue() 
                                  + "\n");

将其作为其来源返回顺序流。

过滤器在流上应用的方法:

返回由与给定谓词相匹配的该流元素的流。

降低在流对象上功能:

使用提供的身份值和关联累积函数对该流的元素进行减少,并返回降低的值

To have a full use of stream functionalities You need to use stream, filter and reduce functions as follow:

// Get the stream from entrySet
String result = map.entrySet().stream()    
      // Filter entries based on your condition
      .filter(val ->  val.getValue() >= 10 
                           && !Objects.equals(val.getKey(), " ") 
                           && val.getKey().length() > 3)  
       // Apply the reduce to combine filtered entries in a single string     
      .reduce("", (stats, val) -> stats 
                                  + val.getKey().toLowerCase() 
                                  + " - " 
                                  + val.getValue() 
                                  + "\n");

The stream method applied to a Collection give a new Stream of the item present in the set:

Returns a sequential Stream with this collection as its source.

The filter method appplied on the stream:

Returns a stream consisting of the elements of this stream that match the given predicate.

The reduce function on the stream object:

Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value

与有条件的流有关hashmap的迭代

懵少女 2025-02-18 09:00:05

谢谢您的评论。我从您的评论中记得,可以通过将脚本读数放置在 body 元素的末尾或使用 window.addeventlistener 来使其能够按预期工作。我很ham愧地说我忘了做一些如此简单的事情。

<!-- index.html -->
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <p id="first-paragraph">Target.</p>
        <script type="text/javascript" src="index.js"></script>
    </body>
</html>

或者

// index.dart
import 'dart:html';

void main() {
  window.addEventListener('DOMContentLoaded', (event) {
    print(querySelector('#first-paragraph')?.innerText);
  });
}

Thank you for your comments. I remembered from your comments and was able to get it to work as expected by placing the script readout at the end of the body element or using window.addEventListener. I am ashamed to say that I forgot to do something so simple.

<!-- index.html -->
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <p id="first-paragraph">Target.</p>
        <script type="text/javascript" src="index.js"></script>
    </body>
</html>

or

// index.dart
import 'dart:html';

void main() {
  window.addEventListener('DOMContentLoaded', (event) {
    print(querySelector('#first-paragraph')?.innerText);
  });
}

飞镖 - `querySelector`找不到元素

懵少女 2025-02-18 04:44:42
<select name="select_multip_values_1[]" multiple="">                                                                                                 
    <option>1</option>
    <option>2</option>
</select>

您可以从请求中获取所有键,然后使用REGEX或包含'value_'之类的filtre键:

$requestKeys = collect($request->all())->keys();
$keys = array();
foreach($requestKeys as $key){
    if(Str::contains($key, 'select_multip_values_'){
         array_push($keys , $key);
    }
}
foreach($keys as $key){
    foreach($request[$key] as $select_option){
        // do something
    }
}
        
<select name="select_multip_values_1[]" multiple="">                                                                                                 
    <option>1</option>
    <option>2</option>
</select>

you can get all keys from request and then filtre keys like 'values_*' with regex or contains 'value_' :

$requestKeys = collect($request->all())->keys();
$keys = array();
foreach($requestKeys as $key){
    if(Str::contains($key, 'select_multip_values_'){
         array_push($keys , $key);
    }
}
foreach($keys as $key){
    foreach($request[$key] as $select_option){
        // do something
    }
}
        

laravel迭代输入字段

懵少女 2025-02-18 00:49:54

网络存储安装的目录(例如NFS或SMB)也有两个配置设置,这些配置也适用于Azure App Service Docker容器中安装的Azure存储的用户:

EnableSendfile Off
EnableMMAP Off

可以为虚拟主机或每个目录设置此设置。

请参阅:

httpps:///httpd.apache.org/docs.org/docs/2.4/ mod/core.html#enableMmap
https:///htttpd.apache.opache.org/docs/ddocs/2.4/mmod/ core.html#enablesEndFile

There are two configuration settings for network storage mounted directories like NFS or SMB that also apply for this usecase of azure storage mounted in azure app service docker container:

EnableSendfile Off
EnableMMAP Off

This can be set for the virtual host or per directory.

See:

https://httpd.apache.org/docs/2.4/mod/core.html#enablemmap
https://httpd.apache.org/docs/2.4/mod/core.html#enablesendfile

文件下载在Azure App服务中的Firefox中失败,并使用安装的文件存储

懵少女 2025-02-17 15:58:18

让我们看看我是否可以为您提供帮助。

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
//enter your code for connecting to the DB after you have verified that there are POSTS


$dbServername = "mysite.com";
$dbUsername = "username";
$dbPassword = "12345";
$dbName = "databasename";

$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
if($conn){ echo "Connected!";}

//mysqli_real_escape_string requires knowing what kind of carset the database is using so it should be put like this.

$firstname   = mysqli_real_escape_string($conn, $_POST['firstname']);
$lastname    = mysqli_real_escape_string($conn, $_POST['lastname']);

$sql = "INSERT INTO registration (firstname, lastname) VALUES ('$firstname', '$lastname')";

mysqli_query($conn, $sql);
mysqli_close($conn);
}
?>

let's see if I can be of help for you.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
//enter your code for connecting to the DB after you have verified that there are POSTS


$dbServername = "mysite.com";
$dbUsername = "username";
$dbPassword = "12345";
$dbName = "databasename";

$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
if($conn){ echo "Connected!";}

//mysqli_real_escape_string requires knowing what kind of carset the database is using so it should be put like this.

$firstname   = mysqli_real_escape_string($conn, $_POST['firstname']);
$lastname    = mysqli_real_escape_string($conn, $_POST['lastname']);

$sql = "INSERT INTO registration (firstname, lastname) VALUES ('$firstname', '$lastname')";

mysqli_query($conn, $sql);
mysqli_close($conn);
}
?>

表格未提交和Innerhtml未更新

懵少女 2025-02-17 10:30:00

我不建议您使用此检查并转到网站方法,但是您可以同时进行循环进行线索。并且您可以在需要使用tk.update()时更新TK。
您可以从螺纹循环设置并在单个TK窗口中使用的VAR获取数据。

I would not suggest using this checking and going to website method, but you could thread the while loops to go at the same time. And you could update tk when you want using tk.update().
You could get Data from vars that the threaded loops are setting and use them in your single tk window.

两种不同的循环在tkinter(python)同时运行

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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