RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

E_d_u_a_r_d's questions

Martin Hope
E_d_u_a_r_d
Asked: 2020-09-14 02:03:23 +0000 UTC

pygame 显示矩形而不是符号

  • 5

我试图用矩阵中的字符来重复场景,所有逻辑都正常工作,唯一的问题是字符没有显示

像这样的东西

在此处输入图像描述

我认为问题是我使用的字体不在项目目录中,但是当我将它插入那里时,没有任何效果

我使用日文字母“片假名”中的字符使用他们的 unicode

这是代码

import os
import pygame as pg
from random import choice, randrange


class Symbol:
    def __init__(self, x, y, speed):
        self.x, self.y = x, y
        self.speed = speed
        self.value = choice(green_katakana)
        self.interval = randrange(5, 30)

    def draw(self, color):
        frames = pg.time.get_ticks()
        if not frames % self.interval:
            self.value = choice(green_katakana if color == 'green' else lightgreen_katakana)
        self.y = self.y + self.speed if self.y < HEIGHT else -FONT_SIZE
        surface.blit(self.value, (self.x, self.y))


class SymbolColumn:
    def __init__(self, x, y):
        self.column_height = randrange(8, 24)
        self.speed = randrange(3, 7)
        self.symbols = [Symbol(x, i, self.speed) for i in range(y, y - FONT_SIZE * self.column_height, -FONT_SIZE)]

    def draw(self):
        [symbol.draw('green') if i else symbol.draw('lightgreen') for i, symbol in enumerate(self.symbols)]


os.environ['SDL_VIDEO_CENTERED'] = '1'
RES = WIDTH, HEIGHT = 1600, 900
FONT_SIZE = 40
alpha_value = 0

pg.init()
screen = pg.display.set_mode(RES)
surface = pg.Surface(RES)
surface.set_alpha(alpha_value)
clock = pg.time.Clock()

katakana = [chr(int('0x30a0', 16) + i) for i in range(96)]
font = pg.font.SysFont('MSMINCHO.TTF', FONT_SIZE, bold=True)
green_katakana = [font.render(char, True, (40, randrange(160, 256), 40)) for char in katakana]
lightgreen_katakana = [font.render(char, True, pg.Color('lightgreen')) for char in katakana]

symbol_columns = [SymbolColumn(x, randrange(-HEIGHT, 0)) for x in range(0, WIDTH, FONT_SIZE)]

while True:
    screen.blit(surface, (0, 0))
    surface.fill(pg.Color('black'))

    [symbol_column.draw() for symbol_column in symbol_columns]

    if not pg.time.get_ticks() % 20 and alpha_value < 170:
        alpha_value += 6
        surface.set_alpha(alpha_value)

    [exit() for i in pg.event.get() if i.type == pg.QUIT]
    pg.display.flip()
    clock.tick(60)
python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-08-27 03:48:18 +0000 UTC

具有响应恢复的最大公共子序列

  • 1

这就是问题所在

给定两个序列,您需要找到并打印它们的最大公共子序列。

规格 输入 输入的第一行包含数字 N - 第一个序列的长度 (1 ≤ N ≤ 1000)。第二行包含第一个序列的成员(由空格分隔) - 模数不超过 10000 的整数。

第三行包含数字 M,即第二个序列的长度(1 ≤ M ≤ 1000)。第四行包含第二个序列的成员(用空格分隔) - 模数不超过 10000 的整数。

输出 要求显示这些序列的最大公共子序列,用空格分隔。

这是我尝试过的

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

using namespace std;

const int N = 1002;

int x[N], y[N], a[N][N];

int main() {

    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);

    int n, m;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
        cin >> y[i];
    }


    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (x[i] == y[j]) {
                a[i][j] = 1 + a[i - 1][j - 1];
            }
            else {
                a[i][j] = max(a[i - 1][j], a[i][j - 1]);
            }
        }
    }

    vector<int> v;

    int i = n, j = m;

    while (i && j) {
        if (x[i - 1] == y[j - 1]) {
            v.push_back(x[i]);
            i--;
            j--;
        }
        else if (a[i - 1][j] == a[i][j]) {
            i--;
        }
        else {
            j--;
        }
    }

    for (int k = v.size() - 1; k >= 0; k--) {
        cout << v[k] << ' ';
    }

    return 0;
}

首先:显示错误答案(例如,在以下输入数据 3 1 2 3 3 2 3 1 的情况下,它显示 3 而不是 2 3 )其次:它发出以下警告: 在此处输入图像描述

c++
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-08-22 03:18:59 +0000 UTC

向右旋转二进制代码

  • 3

今天是个好日子!问题实质如下:有一个数n及其二进制表示,经过一定次数的循环右移后,再次重复二进制表示,需要找出得到的最大数从这些转变之一的十进制表示。

这是我试图做的

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>

using namespace std;

const int N = 1005;

string to_binary(int x) {
    string s;
    do {
        s.push_back('0' + (x & 1));
    } while (x >>= 1);

    reverse(s.begin(), s.end());
    return s;
}

int get_count_of_repeats(string s) {
    if (s.size() == 1) {
        return 0;
    }
    else {
        string z = s;
        int count = 1;

        char c = z[z.size() - 1];
        for (int i = z.size() - 1; i >= 1; i--) {
            z[i] = z[i - 1];
        }
        z[0] = c;

        while (s != z) {
            char ch = z[z.size() - 1];
            for (int i = z.size() - 1; i >= 1; i--) {
                z[i] = z[i - 1];
            }
            z[0] = ch;
            count++;
        }
        return count;
    }
}


int main() {

    int n;
    cin >> n;

    string binary = to_binary(n);

    if (get_count_of_repeats(binary) == 0) {
        cout << n << endl;
    }
    else {
        int mx = -1000007;
        int count = get_count_of_repeats(binary);
        for (int i = 0; i < count; i++) {
            string z = binary;
            char c = z[z.size() - 1];
            for (int j = z.size() - 1; j >= 1; j--) {
                z[i] = z[i - 1];
            }
            z[0] = c;

            mx = max(mx, stoi(z, nullptr, 2));
            binary = z;
        }
        cout << mx << endl;
    }


    return 0;
}

但它给了我以下错误

在此处输入图像描述

请帮我解决问题

c++
  • 2 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-04-18 14:43:12 +0000 UTC

我应该为游戏开发获得 i7-3770 [关闭]

  • 1
关闭 这个问题是题外话。目前不接受回复。

根据帮助中描述的规则,这个问题很可能与俄语中的 Stack Overflow 主题不对应。

2年前关闭。

改进问题

我打算买一台电脑,我将在虚幻引擎中工作。我的预算非常有限。我住在亚美尼亚,这里的商店不多。我已经找到了一个不错的选择,但是处理器有点旧 i7-3770。我可以拿这台电脑吗?

разработка-игр
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-04-01 14:37:07 +0000 UTC

电报机器人不发送消息

  • 0

我正在创建一个购物车机器人,当我发送初始消息时,这里没有任何反应是代码

import COVID19Py
import telebot

covid19 = COVID19Py.COVID19()
bot = telebot.TeleBot('')

@bot.message_handler(commands=['start'])
def start(message):
    send_mess = f"<b>Привет {message.from_user.first_name}!</b>\nВведите страну"
    bot.send_message(message.chat.id, send_mess, parse_mode='html')

bot.polling(none_stop=True)

一切似乎都是正确的,但这是结果 多次发送初始消息,但仍然没有任何效果

python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-04-01 04:36:04 +0000 UTC

创建电报机器人时出现问题

  • 0

我正在构建一个电报机器人来查看有关 covid-19 的信息并为此使用 COVID19Py 库,当我这样做时请求

import COVID19Py

covid19 = COVID19Py.COVID19()

location = covid19.getLocationByCountryCode("US")

print(location)

一小段代码我得到这个错误

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    location = covid19.getLocationByCountryCode("US")
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\COVID19Py\covid19.py", line 103, in getLocationByCountryCode
    data = self._request("/v2/locations", {"country_code": country_code})
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\COVID19Py\covid19.py", line 38, in _request
    response.raise_for_status()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 503 Server Error: Service Unavailable for url: https://coronavirus-tracker-api.herokuapp.com/v2/locations?country_code=US&source=jhu

我怎样才能解决这个问题?

python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-03-25 19:50:49 +0000 UTC

转换 python(pycharm) 项目

  • 0

如何将整个项目转换为一个 .exe 文件以及之后如何转换 .exe -> .dmg

使用第三方库和模块

(.dmg 是 macOS 可执行文件,对于那些不知道的人)

python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-03-15 23:31:38 +0000 UTC

如何使用 cx_Freeze 脚本更改 .exe 文件的图标

  • 0

我用 python 和 pygame 编写了一个游戏并用 cx_Freeze 库编译现在我想更改可执行文件的图标。这是 cx_Freeze 代码

import sys
from cx_Freeze import setup, Executable

base = None

if sys.platform == "win32":
    base = "Win32GUI"

executables = [Executable("main.py", base=base, targetName="PongGame_by_e_d_u_a_r_d.exe")]


packages = ["pygame"]

options = {
    'build_exe': {
        'packages':packages,
    },
}

setup(
    name="PongGame_by_e_d_u_a_r_d",
    options=options,
    version="VERSION_NUMBER e.g. 0.1",
    description='pong game',
    executables=executables
)

在这里添加什么来添加图标?

python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-02-26 03:06:43 +0000 UTC

python中的快速语音识别

  • 4

现在我正在用python和SpeechRecognition做一个语音助手,但是每次我说一个命令,这个命令到文本的转换需要很长时间(5-15秒),非常不愉快。有什么方法可以加快这个过程吗?或者建议另一个图书馆...

这是识别码。

def recognize_cmd():
    r = sr.Recognizer()

    m = sr.Microphone(device_index=1)

    with m as source:
        print("---------")
        r.pause_threshold = 0.5
        r.adjust_for_ambient_noise(source, duration=1)
        audio = r.listen(source)

    try:
        cmd = r.recognize_google(audio, language='en-EN').lower()
        print("[log]User - " + cmd + '\n---------')
    except sr.UnknownValueError:
        talk("Voice is not recognized!")
        cmd = recognize_cmd()

    return cmd

PS最好该库具有这样的功能,adjust_for_ambient_noise() 并且如果可能的话,建议一个可以离线工作的库

python
  • 1 个回答
  • 10 Views
Martin Hope
E_d_u_a_r_d
Asked: 2020-02-24 14:23:53 +0000 UTC

IndentationError: unindent 在语音助手创建过程中不匹配任何外部缩进级别 python

  • -1

当我开始编写代码来创建我的语音助手时,我在使用Speech RecognitionPython 库时遇到了问题。
错误: IndentationError: unindent does not match any outer indentation level

这是发生错误的代码部分:r = sr.Recognizer() 这是目前的完整代码。

import os
import sys
import time
import speech_recognition as sr
from fuzzywuzzy import fuzz
import pyttsx3
import datetime

opts = {
    "alias": ('jarvis', 'jervis', 'jirves', 'jurves', 'jervas'
              'jalvis', 'jelvis', 'jilves', 'julves', 'jelvas'),
    "tbr": ('say', 'tell', 'show', 'how much', 'will', 'would',
            'could', 'may', 'can', 'must', 'the'),
    "cmds": {
        "ctime": ('current time', 'time', 'what time is it'),
        "radio": ('turn on the music', 'turn on the radio',
                  'play radio'),
        "jokes": ('tell a joke', 'do you know any jokes',
                    'make me laugh')
    }
}

# functions

def speak(what):
    print(what)
    speak_engine.say(what)
    speak_engine.runAndWait()
    speak_engine.stop()



#start

 r = sr.Recognizer()
 m = sr.Microphone(device_index=1)

 with m as source:
     r.adjust_for_ambient_noise(source)


speak_engine = pyttsx3.init()

speak("Good day my master")
speak("Jarvis is listening")

# stop_listening = r.listen_in_background(m, callback)

# while True:
#     time.sleep(0.1) # infinite loop

所有库都用 pip 安装好,所有库都经过测试

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