小编Lal*_*iya的帖子

错误:db 类型为 dbm.gnu,但该模块在 windows 中不可用

我在 Windows 机器上安装了 python3.6。打开 my.db 文件时出现以下错误。

my.db 文件由我的程序在 python3.6 的 ubuntu16.04 中创建,使用搁置模块。

In [1]: import shelve

In [2]: db = shelve.open("etc/my.db")
---------------------------------------------------------------------------
error                                    Traceback (most recent call last)
<ipython-input-2-b4828c8ee6e1> in <module>()
----> 1 db = shelve.open("etc/my.db")

c:\Python36\Lib\shelve.py in open(filename, flag, protocol, writeback)
    241     """
    242
--> 243     return DbfilenameShelf(filename, flag, protocol, writeback)

c:\Python36\Lib\shelve.py in __init__(self, filename, flag, protocol, writeback)
    225     def __init__(self, filename, flag='c', protocol=None, writeback=False):
    226         import dbm
--> 227         Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
    228
    229

c:\Python36\Lib\dbm\__init__.py in …
Run Code Online (Sandbox Code Playgroud)

shelve dbm python-3.6

7
推荐指数
1
解决办法
2262
查看次数

在一些结果后如何停止 papaparse 流

我正在使用PapaPase解析大 CSV 文件,使用块模式。

我正在验证 csv 数据,我想在验证失败时停止流式传输。

但是经过一些解析后,我无法停止流式传输。

我试图停止使用块回调中的 return false ,但它不起作用。

下面是代码。

$("#fileselect").on("change", function(e){
    if (this.files.length) {
        var file = this.files[0]
        count = 0;
        Papa.parse(file, {
            worker: true,
            delimiter: "~~",
            skipEmptyLines:true,
            chunk: function (result) {
                count += result.data.length;
                console.clear();
                console.log(count);
                if (count>60000) {
                    return false;
                }
            },
            complete: function (result, file) {
                console.log(result)
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

javascript node.js papaparse

5
推荐指数
1
解决办法
2218
查看次数

如何检测pyside2中Qwebengine内部的按钮点击

我在 pyside2 中编写了一个应用程序,它在 QWebEngine 中打开了一个网页。

该网页有 2 个按钮,我不明白如何检测 pyside2 应用程序模块中的按钮点击,我需要对该按钮点击执行其他操作。

例子

下面是我的代码

from PySide2.QtWidgets import QApplication
from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
from PySide2.QtCore import QUrl

class WebEnginePage(QWebEnginePage):
    def __init__(self, *args, **kwargs):
        QWebEnginePage.__init__(self, *args, **kwargs)
        self.featurePermissionRequested.connect(self.onFeaturePermissionRequested)

    def onFeaturePermissionRequested(self, url, feature):
        if feature in (QWebEnginePage.MediaAudioCapture, 
            QWebEnginePage.MediaVideoCapture, 
            QWebEnginePage.MediaAudioVideoCapture):
            self.setFeaturePermission(url, feature, QWebEnginePage.PermissionGrantedByUser)
        else:
            self.setFeaturePermission(url, feature, QWebEnginePage.PermissionDeniedByUser)

app = QApplication([])

view = QWebEngineView()
page = WebEnginePage()
page.profile().clearHttpCache()
view.setPage(page)
view.load(QUrl("https://test.webrtc.org/"))

view.show()
app.exec_()
Run Code Online (Sandbox Code Playgroud)

下面是输出:

在此处输入图片说明

现在我只想在用户单击“开始”按钮时关闭我的应用程序。

python pyside2 qwebengineview qwebenginepage qtwebchannel

5
推荐指数
1
解决办法
1276
查看次数

如何在不带微秒的情况下在Django中添加DateTimeField

我在django 1.8和mysql 5.7中编写django应用程序。

下面是我编写的模型:

class People(models.Model):
    name = models.CharField(max_length=20)
    age = models.IntegerField()
    create_time = models.DateTimeField()

    class Meta:
        db_table = "people"
Run Code Online (Sandbox Code Playgroud)

上面的模型创建下表:

mysql> desc people;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | NO   |     | NULL    |                |
| age         | int(11)     | NO   |     | NULL    |                | 
| create_time | datetime(6) | NO …
Run Code Online (Sandbox Code Playgroud)

python mysql django

4
推荐指数
1
解决办法
3165
查看次数

带有圆形图像的 Qlabel

我想在 QT/PySide2 应用程序中显示圆形图像。

下面是我试过的代码。

self.statusWidget = QLabel()
img = QImage(":/image.jpg").scaled(49, 49, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
self.statusWidget.setPixmap(QPixmap.fromImage(img))
self.statusWidget.setStyleSheet("border-radius:20px")
Run Code Online (Sandbox Code Playgroud)

我得到了低于输出。

在此处输入图片说明

我想要像下面这样的 Qlabel。

在此处输入图片说明

python qt pyside pyqt5 pyside2

3
推荐指数
1
解决办法
2406
查看次数