RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

arnold's questions

Martin Hope
arnold
Asked: 2022-06-22 00:40:50 +0000 UTC

在程序启动时关闭控制台

  • 1

我遇到了这样一个问题:我用PyQt5写了一个程序,它运行良好,我在pyinstaller的帮助下制作了一个.exe文件,因为我会经常使用它,当我运行可执行文件时,除了它,控制台打开。是否有可能以某种方式阻止控制台的打开?

先感谢您在此处输入图像描述

python
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-05-18 04:52:44 +0000 UTC

用字符替换字符串

  • -1

面临这样一个问题:是否有可能以某种方式转换以下代码使用string

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str[3] = { "Anna", "Max", "Dan" };
    for (int i = 0; i < strlen(str); i++) {
        cout << str[i] << " ";
    }
}

编码使用char?我知道是什么char将单词分成字符,所以我不确定这是否可能。请帮我弄清楚!

c++
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-05-05 17:41:23 +0000 UTC

安排8个皇后,使它们不会被对方击中

  • 1

任务设置如下:你需要在一个棋场上放置8个皇后,这样它们就不会受到对方的攻击。

我在 C++ 中实现了这个任务,如下所示:

#include <iostream> 
using namespace std;

int main() {
    setlocale(LC_ALL, "ru");
    int q[8], c, i;
    int count = 1;
    q[0] = 0;
    c = 0;


NC:
    c++;
    if (c == 8) goto print;
    q[c] = -1;


NR:
    q[c]++;
    if (q[c] == 8) goto back;

    for (i = 0; i < c; i++) {
        if ((q[i] == q[c]) || ((c - i) == abs(q[c] - q[i]))) goto NR;
    }
    goto NC;


back:
    c--;
    if (c == -1) return 0;
    goto NR;

print:
    cout << "---------------------------------";
    cout << endl;
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (j == q[i]) {
                cout << "| Ф ";
            }
            else {
                cout << "|   ";
            }
        }
        cout << "|";
        cout << endl;
        cout << "---------------------------------";
        cout << endl;
    }
    system("pause");

    return 0;
}

告诉我如何修复我的代码以便我不使用goto?我将不胜感激。

c++
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-29 22:25:23 +0000 UTC

在目录中查找文件

  • 1

如何在 Python 中找到 .txt 类型的文件,同时文件的名称以“result”开头。也就是说,在我的文件夹中的文件是:result_275.txt, result_351.txt,task.txt

程序如何找到这些文件并例如显示它们的名称?

python
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-27 03:09:31 +0000 UTC

获取系统使用信息并将其显示在图表中[关闭]

  • 1
关闭。这个问题需要具体说明。目前不接受回复。

想改进这个问题? 重新构建问题,使其只关注一个问题。

10 个月前关闭。

改进问题

如何构建每秒更新的已用磁盘空间的散点图?我很乐意提供帮助!

我们需要这样的时间表,因为对于应用程序的运行,磁盘空间不会发生显着变化(除非我们删除一些东西)。

在此处输入图像描述

python
  • 2 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-27 01:13:17 +0000 UTC

如何在一个 PyQt5 按钮单击上运行 2 个或更多功能?

  • 0

单击按钮时是否可以执行两个功能?我请求你的帮助!

这是我的窗口类:

class Window_3(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_regit()
        self.ui.setupUi(self)
        self.ui.pushButton3.clicked.connect(self.go_end)
        self.ui.pushButton4.clicked.connect(self.processor) #  хочу вызвать processor и matherboard

    def go_end(self):
        self.hide()

    def processor(self):
        name_proc = "ProcessorNameString"
        n_p = True
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
            with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0") as sub_key:
                try:
                    i = 0
                    while n_p:
                        path_value = winreg.EnumValue(sub_key, i)
                        if name_proc == path_value[0]:
                            self.ui.label_proc_info.setText(f"{path_value[1]}")
                            print(f"Proseccor: {path_value[1]}")
                            n_p = False
                        else:
                            i += 1
                except OSError:
                    print("processor not found")
            winreg.CloseKey(sub_key)
        winreg.CloseKey(hkey)

    def matherboard(self):
        name_proc = "BaseBoardproduct"
        n_p = True
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
            with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\BIOS\\0") as sub_key:
                try:
                    i = 0
                    while n_p:
                        path_value = winreg.EnumValue(sub_key, i)
                        if name_proc == path_value[0]:
                            self.ui.label_proc_info_2.setText(f"{path_value[1]}")
                            n_p = False
                        else:
                            i += 1
                except OSError:
                    pass
            winreg.CloseKey(sub_key)
        winreg.CloseKey(hkey)
pyqt5
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-24 05:21:37 +0000 UTC

将数组元素循环左移 k 步

  • 1

我能够实现太平庸的代码,以便将数组循环移动一个值。您需要以某种方式通过 k 值实现移位,并且您不能使用任何函数,只能使用循环。我请求你的帮助!

我的代码:

#include <iostream>

using namespace std;

int main()
{
    const int N = 4;
    int arr[N] = { 1, 2, 3, 4 };

    int el = arr[0];
    for (int i = 1; i < N; ++i)
        arr[i - 1] = arr[i];
    arr[N - 1] = el;

    for (int i = 0; i < N; ++i)
        cout << arr[i] << " ";
}

c++
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-11 00:50:22 +0000 UTC

图来自符号

  • 0

我最近开始学习 C++,我的代码很蹩脚。您需要输出以下内容:

在此处输入图像描述

我怎样才能缩短我的代码(我相信你可以)?

#include <iostream>
#include <string>

using namespace std;

int main() {
    setlocale(LC_ALL, "ru");

    string simvol = "*";
    
    int control = 7;

    for (int j = 0; j < control; j++) {
        cout << simvol << " ";
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        if ((j == 0) || (j == control - 1)) {
            cout << "  ";
        }
        else {
            cout << simvol << " ";
        }   
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        if ((j == 0) || (j == 1) || (j == control - 1) || (j == control - 2)) {
            cout << "  ";
        }
        else {
            cout << simvol << " ";
        }
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        if ((j == 0) || (j == 1) || (j == 2) || (j == control - 1) || (j == control - 2) || (j == control - 3)) {
            cout << "  ";
        }
        else {
            cout << simvol << " ";
        }
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        if ((j == 0) || (j == 1) || (j == control - 1) || (j == control - 2)) {
            cout << "  ";
        }
        else {
            cout << simvol << " ";
        }
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        if ((j == 0) || (j == control - 1)) {
            cout << "  ";
        }
        else {
            cout << simvol << " ";
        }
    }
    cout << endl;
    for (int j = 0; j < control; j++) {
        cout << simvol << " ";
    }
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-04-05 16:21:21 +0000 UTC

重新启动应用程序

  • 1

如何跟踪应用程序的打开副本并关闭主要副本?

我读到互斥量和信号量用于此目的,但我不知道如何将其与PyQt5连接起来。

例如,我启动一个应用程序,启动它后,我再次打开它。例如,我如何警告应用程序已经在运行?

我希望能得到你的帮助。

python
  • 1 个回答
  • 10 Views
Martin Hope
arnold
Asked: 2022-03-16 02:18:58 +0000 UTC

工作 5 分钟后关闭程序

  • 1

以下情况:我需要以某种方式,使用注册表,在5工作几分钟后关闭程序并要求,例如,购买主要订阅。

我所做的最多是在一定数量的启动后实施关闭。

import winreg
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
number, start_program = "", True


def software():
    with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
        with winreg.OpenKey(hkey, "SOFTWARE") as sub_key:
            try:
                i = 0
                while True:
                    path_value = winreg.EnumKey(sub_key, i)
                    print(f"{path_value}")
                    i += 1
            except OSError:
                print()
        winreg.CloseKey(sub_key)
    winreg.CloseKey(hkey)


def read_key_software():
    with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
        with winreg.OpenKey(hkey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") as sub_key:
            try:
                i = 0
                while True:
                    path_value = winreg.EnumValue(sub_key, i)
                    print(f"{path_value}")
                    i += 1
            except OSError:
                print("")
        winreg.CloseKey(sub_key)
    winreg.CloseKey(hkey)


def matherboard():
    name_board = "BaseBoardProduct"
    n_b = True
    with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
        with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\BIOS") as sub_key:
            try:
                i = 0
                while n_b:
                    path_value = winreg.EnumValue(sub_key, i)
                    if name_board == path_value[0]:
                        print(f"Matherboard: {path_value[1]}")
                        n_b = False
                    else:
                        i += 1
            except OSError:
                print("matherboard not found")
        winreg.CloseKey(sub_key)
    winreg.CloseKey(hkey)
    print("")


def processor():
    name_proc = "ProcessorNameString"
    n_p = True
    with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
        with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0") as sub_key:
            try:
                i = 0
                while n_p:
                    path_value = winreg.EnumValue(sub_key, i)
                    if name_proc == path_value[0]:
                        print(f"Proseccor: {path_value[1]}")
                        n_p = False
                    else:
                        i += 1
            except OSError:
                print("processor not found")
        winreg.CloseKey(sub_key)
    winreg.CloseKey(hkey)
    print("")


def SPLab():
    global number, start_program
    path = False
    with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkey:
        with winreg.OpenKey(hkey, "SOFTWARE") as sub_key:
            winreg.CreateKey(sub_key, "SPLab")
    winreg.CloseKey(hkey)
    with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkey:
        with winreg.OpenKey(hkey, "SOFTWARE\\SPLab", 0, winreg.KEY_READ) as sub_key:
            try:
                num = winreg.EnumValue(sub_key, 0)
                path = True
                start = num[1]
                if int(start) >= 10:
                    start_program = False
            except OSError:
                path = False
        winreg.CloseKey(sub_key)
        with winreg.OpenKey(hkey, "SOFTWARE\\SPLab", 0, winreg.KEY_WRITE) as sub_key:
            if path:
                start = int(start) + 1
            else:
                start = "1"
            winreg.SetValueEx(sub_key, "NamberOfStarts", 0, winreg.REG_SZ, str(start))
        winreg.CloseKey(sub_key)
    winreg.CloseKey(hkey)
    number = start
    print("")


class mainWin(QMainWindow):
    def __init__(self):
        super(mainWin, self).__init__()
        self.setWindowTitle("Program")

        if start_program:
            self.setGeometry(1000, 300, 580, 270)
            self.setStyleSheet("background : lightyellow;")
            self.b1 = QtWidgets.QPushButton(self)
            self.b1.setGeometry(20, 20, 250, 70)
            self.b1.setStyleSheet("background : lightgreen; font-size : 20px")
            self.b1.setText("software")
            self.b1.clicked.connect(software)
            self.b2 = QtWidgets.QPushButton(self)
            self.b2.setGeometry(300, 20, 250, 70)
            self.b2.setStyleSheet("background : lightgreen; font-size : 20px")
            self.b2.setText("read_key_software")
            self.b2.clicked.connect(read_key_software)
            self.b3 = QtWidgets.QPushButton(self)
            self.b3.setGeometry(20, 120, 250, 70)
            self.b3.setStyleSheet("background : lightgreen; font-size : 20px")
            self.b3.setText("matherboard")
            self.b3.clicked.connect(matherboard)
            self.b4 = QtWidgets.QPushButton(self)
            self.b4.setGeometry(300, 120, 250, 70)
            self.b4.setStyleSheet("background : lightgreen; font-size : 20px")
            self.b4.setText("processor")
            self.b4.clicked.connect(processor)
            self.l5 = QtWidgets.QLabel(self)
            self.l5.setGeometry(20, 210, 250, 50)
            self.l5.setText(f"Number of starts: {number}")
            self.l5.setStyleSheet("font-size : 20px")
        else:
            self.setGeometry(800, 400, 850, 300)
            self.setStyleSheet("background : white;")
            self.l1 = QtWidgets.QLabel(self)
            self.l1.setGeometry(25, 100, 1000, 70)
            self.l1.setText("Buy the full version of the program!")
            self.l1.setStyleSheet("font-size : 50px")


if __name__ == "__main__":
    SPLab()
    app = QApplication(sys.argv)
    mwin = mainWin()
    mwin.show()
    print("")
    sys.exit(app.exec_())
python
  • 1 个回答
  • 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