RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-373084

Lev145's questions

Martin Hope
Lev145
Asked: 2020-08-27 17:00:39 +0000 UTC

在 QT 窗口之间共享数据

  • 2

我尝试了很长时间在2个窗口之间进行调用,并编写了以下代码:

主窗口.cpp:

...
// Слот на изменения textEdit
void MainWindow::recieveData(QString str){
    ui->textEdit->setText(str);
    qDebug() << "2";

}
...
// Открытие другого окна
void MainWindow::on_action_select_theme_triggered(){

    Themes *ad = new Themes;
    ad->show();
}

主窗口.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


public slots:
    void recieveData(QString str);

private slots:
    void on_action_select_theme_triggered();

public:
    Ui::MainWindow *ui;


};
#endif // MAINWINDOW_H

主题.cpp:

...
Themes::Themes(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Themes)
{



    ui->setupUi(this);





    QStringList strings;
    strings << "Дефолт" << "Dark Theme" << "Sea Theme";


    ui->listWidget->addItems(strings);


    MainWindow * dialog2 = new MainWindow(this);

    qDebug() << "1";

    // emit signalFromDialog("Test text");
    connect(this,SIGNAL(signalFromDialog(QString)),dialog2,SLOT(recieveData(QString))
    emit signalFromDialog("Test text");
    );
    ...

}

主题.h:

#ifndef THEMES_H
#define THEMES_H

#include <QWidget>

namespace Ui {
class Themes;
}

class Themes : public QWidget
{
    Q_OBJECT

public:
    explicit Themes(QWidget *parent = nullptr);
    ~Themes();


signals:
    void signalFromDialog(QString str);


private slots:
    void on_Button_GetItem_clicked();

private:
    Ui::Themes *ui;
};

#endif // THEMES_H

同时,控制台中显示 2 ,我通过 调用qDebug() << "2";,但尽管如此,ui->textEdit->setText(str);由于某种原因,该操作没有执行,我该如何修复代码以从 theme.cpp 更改,从 mainwindow.cpp 更改 textEdit ?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-04-10 17:48:25 +0000 UTC

解析来自 Youtube 频道的视频(Python、BeautifulSoup、请求)

  • 1

有这个代码:

from bs4 import BeautifulSoup
import requests

ycid = input('Введите код-идентификатор канала: ') #получение идентификатор канала

url = f'https://www.youtube.com/channel/{ycid}' #создание ссылки на канал
HEADERS = {'User-Agent': 'Mozilla/5.0 (Windows NT 7.0; Win32; x32) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
print(f'Парсим с канала: {url}')
html = requests.get(url, headers = HEADERS )
html = html.text
soup = BeautifulSoup(html, 'lxml')

div_tags = soup.find_all('div', {'class': 'style-scope ytd-grid-video-renderer', 'id': 'dismissable'})
print(div_tags)
a_tags = [div.find('a') for div in div_tags]
print(a_tags)
url_img = [a['href'] for a in a_tags]
print(url_img)

该代码应该解析来自指定频道的第一个视频,但它返回空列表。

结果:

Введите код-индитификатор канала: UCviSYAcwdnDX1UoRzAHYgNg
Парсим с канала: https://www.youtube.com/channel/UCviSYAcwdnDX1UoRzAHYgNg
[]
[]
[]

在此处输入图像描述

如何更正代码?

python
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-04-01 01:24:15 +0000 UTC

如何从以前收到的数据创建目录

  • 0

比如有一个未知的服务器,我取服务器id。从另一台服务器,我也通过收集命令获取它的 id。现在我们需要用我们的 id 创建一个文件夹。

我试过这样:

pach1 = f'"D:\Desktop\test\{команда взятия id сервера}"'
os.makedirs(pach1)

但没有任何效果

python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-26 14:30:31 +0000 UTC

解析只产生一张图像

  • 0

这是代码python:

import requests
from bs4 import BeautifulSoup

# переменная показывающая номер домена
a = 0

def parse_img(g):
    for i in range(g):
        global a
        a += 1
        url = 'https://www.1zoom.ru/%D0%96%D0%B8%D0%B2%D0%BE%D1%82%D0%BD%D1%8B%D0%B5/%D0%9A%D0%BE%D1%82%D1%8F%D1%82%D0%B0/t2/'
        HEADERS = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}

        html = requests.get(url + str(a), headers = HEADERS )
        print(html.url)
        html = html.text
        soup = BeautifulSoup(html, 'lxml')

        div_tags = soup.find_all('div', {'id': 'suda'})
        
        img_tags = [div.find('img') for div in div_tags]

        url_img = [img['src'] for img in img_tags]
        return url_img
    
# Парсинг первого домена
print(parse_img(1))

在此处输入图像描述

结果,仅从站点解析了一张图像,而不是站点上的所有图像

结论:

https://www.1zoom.ru/%D0%96%D0%B8%D0%B2%D0%BE%D1%82%D0%BD%D1%8B%D0%B5/%D0%9A%D0%BE%D1%82%D1%8F%D1%82%D0%B0/t2/1/
['https://s1.1zoom.ru/prev2/581/Ginger_color_Cute_Kittens_580356_300x214.jpg']

我有一个问题,如何解析站点域中的所有图像,而不仅仅是一个?

python
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-22 20:25:56 +0000 UTC

无法将应用上传到 Google Play

  • 0

我想把我的应用程序放到 Google Play 上,然后我遇到了困难: 在此处输入图像描述

怎么没优化?什么没有优化?以及如何优化它?

android
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-22 15:47:28 +0000 UTC

内容解析(Python、BeautifulSoup、请求)

  • 0

这是代码:

from bs4 import BeautifulSoup

html = requests.get('https://kaliningrad.bankiros.ru/currency/').text
soup = BeautifulSoup(html, 'lxml')

div_tags1 = soup.find_all('td', {'class': 'currency-value'})
img_tags1 = [div.find('span') for div in div_tags1]

image_src1 = [img['data-curse-val'] for img in img_tags1]

valist = list(image_src1)

print(valist)

我还在学习解析,我不明白为什么在输出中传递了一个空列表,因为我似乎一如既往地做了所有事情。

如何从https://kaliningrad.bankiros.ru/currency/解析货币?

在此处输入图像描述

python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-21 16:51:35 +0000 UTC

第三方模块未导入 Buildozer(Python、Kivy)

  • 0

在构建到 *.apk 时,我使用了第三方 pycbrf 模块

我安装了模块并将其插入到项目中:

在此处输入图像描述

from pycbrf.toolbox import ExchangeRates

并且还插入到初始化文件(buildozer.spec)中:

在此处输入图像描述

一切都组装好了,但是在安装 * .apk 时,应用程序无法打开。

如何解决这个问题?

python
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-18 02:12:29 +0000 UTC

脚本不适用于 BeautifulSoup 和请求 (Python3x)

  • 0

我试图解析网站上的图片地址(https://amitego.ru/)

结果是这样的:

import requests
from bs4 import BeautifulSoup

HEADERS = {
'user-agent': '*Скрыто*',
'accept': '*/*'

}

def get_html(url):
    r = requests.get(url, headers=HEADERS)
    return r.text

def get_images(html):
    soup = BeautifulSoup(html, 'lxml')
    a = soup.find('div', class_='pp-posts-container').find_all('div', class_='pp-post-thumbnail')
    images = []

    for i in images:
        img = a.find('a').get('src')
        images.append(a)
    return images



def main():
    url = 'https://amitego.ru/'
    all_images = get_images(get_html(url))

    for i in all_images:
        print(i)

if __name__ == '__main__':
    main()

在此处输入图像描述 解析时,它不会产生任何东西,我不知道为什么( 在此处输入图像描述 请告诉我我可能错在哪里。

python-3.x
  • 2 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-13 06:20:03 +0000 UTC

未导入 Kivy MD 的小部件

  • 0

这是一个简单应用程序的代码:

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout

from kivymd.app import MDApp
from kivymd.theming import ThemeManager



Builder.load_string =('''


<Cont>:
    rows: 2

    c: C
    c1: C1
    c2: C2
    m1: M1
    m2: M2

    BoxLayout:
        orientation: 'vertical'
        padding: [70]
        spacing: 100

        MDTextField:
            id: C
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        MDTextField:
            id: C1
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        MDTextField:
            id: C2
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        MDTextField:
            id: M1
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        MDTextField:
            id: M2
            size_hint: (1, .1)
            font_size: (100)
            multiline: False



    BoxLayout:
        size_hint: (1,.2)
        padding: [40,0,40,20]

        MDIconButton:
            text: 'test'
            on_press: root.cal()

''')

def get(c1,c2,m1,m2,c):

    if c == '?':
        c = 1
    if c1 == '?':
        c1 = 1
    if c2 == '?':
        c2 = 1
    if m1 == '?':
        m1 = 1
    if m2 == '?':
        m2 = 1




    c1 = float(c1)
    c2 = float(c2)
    m1 = float(m1)
    m2 = float(m2)
    c = float(c)

    Ans_C = str((c1*m1+c2*m2)/(m1+m2))
    Ans_C1 = str((c*m1+c*m2-c2*m2)/(m1))
    Ans_C2 = str((c*m1+c*m2-c1*m1)/(m2))
    Ans_M1 = str((c2*m2-c*m2)/(c-c1))
    Ans_M2 = str((c1*m1-c*m1)/(c-c2))



    return {
    'C': Ans_C,
    'C1': Ans_C1,
    'C2': Ans_C2,
    'M1': Ans_M1,
    'M2': Ans_M2
    }



class Cont(GridLayout):

    def cal(self):



        i1 = self.c1.text
        i2 = self.c2.text
        i3 = self.m1.text
        i4 = self.m2.text
        i5 = self.c.text

        gett = get(i1,i2,i3,i4,i5)


        if self.c.text == '?':
            self.c.text = gett.get('C')
        if self.c1.text == '?':
            self.c1.text = gett.get('C1')
        if self.c2.text == '?':
            self.c2.text = gett.get('C2')
        if self.m1.text == '?':
            self.m1.text = gett.get('M1')
        if self.m2.text == '?':
            self.m2.text = gett.get('M2')




class App(App):
    theme_cls = ThemeManager()
    title = 'Test'

    def build(self):
        self.theme_cls.theme_style = 'Dark'


        return Cont()

if __name__ == "__main__":
    App().run()

并且由于某种原因,应用程序在启动时出现空白屏幕: 在此处输入图像描述 我搜索并重新阅读了很多文档,但没有找到答案,我的错误在哪里?

同时,kivy MD 中的 ThemeManager 工作,很可能问题出在我的代码中不起作用的小部件中。

python
  • 2 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-12 22:42:02 +0000 UTC

kivy 中的错误(TypeError:不能将序列乘以“str”类型的非整数)

  • 0

Python代码:

...
def get(a,b,c,d):

    float(a)
    float(b)
    float(c)
    float(d)
    Ans = str((a*c+b*d)/(c+d))

    return {'C':Ans}


class Cont(GridLayout):

    def cal(self):



        i1 = self.c1.text
        i2 = self.c2.text
        i3 = self.m1.text
        i4 = self.m2.text

        gett = get(i1,i2,i3,i4)


        if self.c.text == '?':
            print(gett.get('C'))



class App(App):
    def build(self):



        return Cont()

...

基维代码:

<Cont>:
    rows: 2

    c: C
    c1: C1
    c2: C2
    m1: M1
    m2: M2

    BoxLayout:
        orientation: 'vertical'
        padding: [70]
        spacing: 100

        TextInput
            id: C
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        TextInput
            id: C1
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        TextInput
            id: C2
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        TextInput
            id: M1
            size_hint: (1, .1)
            font_size: (100)
            multiline: False
        TextInput
            id: M2
            size_hint: (1, .1)
            font_size: (100)
            multiline: False



    BoxLayout:
        size_hint: (1,.2)
        padding: [40,0,40,20]

        Button:
            text: 'test'
            on_press: root.cal()

单击按钮时,会出现错误: 在此处输入图像描述

傻了半天不知道怎么解决?(刚开始学*.kv语言,以前不用它写)

你能帮忙吗,有必要从用户输入的值的TextInputs中填写,而不是'?答案写在输出端(变量 Ans)。

python
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-06 16:10:21 +0000 UTC

如何在kivy上确定android的屏幕尺寸

  • 0

你能帮我吗。

我需要python Kivy来确定手机显示屏的长度和高度以进行应用适配,因为 比例是已知的。

这可以以某种方式完成吗?

android
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-05 00:18:30 +0000 UTC

将数据传递给函数的问题

  • 2

我不想画很多东西并将代码从按钮传递给参数,但是当pushButton按下按钮 ( ) 时,什么也没有发生。

对于任何人来说,一切都很容易解决,但我没有想到什么。

告诉我您需要如何更改代码,以便将您按下的按钮的编号记录在math和中。realmath

math = ""
realmath = ""
def null(x):
    global math, realmath
    realmath += str(x)
    math += str(x)
    print(realmath)             

def slot():
    pass

ui.pushButton.clicked.connect(null(0))
ui.pushButton_7.clicked.connect(slot) #1
ui.pushButton_8.clicked.connect(slot) #2
ui.pushButton_5.clicked.connect(slot) #3
ui.pushButton_11.clicked.connect(slot) #4
ui.pushButton_12.clicked.connect(slot) #5
ui.pushButton_9.clicked.connect(slot) #6
ui.pushButton_15.clicked.connect(slot) #7
ui.pushButton_16.clicked.connect(slot) #8
ui.pushButton_13.clicked.connect(slot) #9

ui.pushButton_2.clicked.connect(slot) # .
ui.pushButton_4.clicked.connect(slot) # +
ui.pushButton_6.clicked.connect(slot) # -
ui.pushButton_10.clicked.connect(slot) # x
ui.pushButton_14.clicked.connect(slot) # /
ui.pushButton_18.clicked.connect(slot) # (
ui.pushButton_19.clicked.connect(slot) # ^
ui.pushButton_20.clicked.connect(slot) # )

ui.pushButton_17.clicked.connect('C')

ui.pushButton_3.clicked.connect('=')
python
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-03-04 00:29:10 +0000 UTC

在 Buildozer (Python kivy) 中创建 Apk 时出错

  • 0

我试图从 python kivy 代码制作一个 apk 文件。安装 buildozer 并运行它(buildozer android debug)。但最后我得到了一个错误:在此处输入图像描述

你能帮忙吗!!!

android
  • 1 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-02-20 23:47:45 +0000 UTC

在 python 中处理两个列表(if、in、&)

  • 0

有一个代码:

test0 = [  ]
test1 = ['a1','a2','a3','b1','b2','b3','c1','c2','c3']

while True:
    p = str(input("Input: "))
    test0.append(p)
    if list(set(test0[-1]) & set(test1)):
        print('True')
    else:
        print('False')

结论:

Input: a1
False
Input: teat
False
Input: c1
False
Input: wtf?
False
Input:

只要p值在test1字典中,代码就应该显示True,但我在某处犯了错误。在互联网上搜索答案,我找不到它。

你能告诉我我在哪里搞砸了。

python
  • 2 个回答
  • 10 Views
Martin Hope
Lev145
Asked: 2020-02-20 02:10:39 +0000 UTC

Python,if - in on 列表如何工作?

  • 0

有一个代码:

datap1 = ["a3","a2","b2"]

if "a1" in datap1:
    print("1")
if "a2" in datap1:
        print("2")
if "a3" in datap1:
        print("3")
if "b1" in datap1:
        print("4")
if "b2" in datap1:
        print("5")
if "b3" in datap1:
        print("6")
if "c1" in datap1:
        print("7")
if "c2" in datap1:
        print("8")
if "c3" in datap1:
        print("9")



if ("a1" and "b1" and "c1") or ("a2" and "b2" and "c2") or ("a3" and "b3" and "c3") or ("a1" and "a2" and "a3") or ("b1" and "b2" and "b3") or ("c1" and "c2" and "c3") or ("a1" and "b2" and "c3") or ("c1" and "b2" and "a3") in list(datap1):
        print('Игрок выиграл!')
        exit()
else:
    print("game over")

从逻辑上讲,它应该在游戏结束时显示,玩家赢了!

你能帮忙写代码吗(这样它只输出玩家赢了!)

并请解释如何使用and和or在列表中实现条件。

提前致谢!

附言。谷歌搜索,没有找到答案。

python
  • 3 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5