RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

全部问题

Martin Hope
alexWithoutBeard
Asked: 2025-04-28 20:34:32 +0000 UTC

使用函数,从有效的 html 代码中获取所有 src 图像

  • 5

有必要实现 getSrc(),它接收一段有效的(即没有错误编写的)html 代码作为输入,该代码可以包含多个图像。获取图像的src属性的值。该属性可以用单引号或双引号引起来,例如,src="test.png", src='test.png'。

src 返回字符串

我得到以下信息:

function getSrc(html) {
  let str = html.toLowerCase();
  let pos = 0;
  let res = ''
  let k = str.indexOf('<img ');
  let src = str.indexOf("src=", k);
  while (str.indexOf('<img ', pos + 1) != -1) {
    let open =
      str.indexOf('"', src) != -1 ?
      str.indexOf('"', src) :
      str.indexOf("'", src);
    let close =
      str.indexOf('"', open + 1) != -1 ?
      str.indexOf('"', open + 1) :
      str.indexOf("'", open + 1);
    pos += close;
    res += str.slice(open + 1, close) + ' ';

  }

  return res

}

getSrc('<table><tr><td><img width="200" src="google.jpg"></td></tr><tr><td><img width="200" src='
  chrome.jpg '></td></tr><tr><td><img width="200" src="safari.jpg"></td></tr><tr><td><img width="200" src="edge.jpg"></td></tr></table>')

它应该输出:google.jpg chrome.jpg safari.jpg edge.jpg。我得到:google.jpg google.jpg google.jpg google.jpg

我明白错误在于我将相同的 src 传递给 while,但如何修复它......有趣的是我在 React 中编写组件,但我被这个困住了)

javascript
  • 2 个回答
  • 48 Views
Martin Hope
geo
Asked: 2025-04-28 18:28:02 +0000 UTC

自定义异常集存储在哪里?

  • 5

为了在类中使用,我需要一组异常,我从 Exceptions 继承并将该组异常存储在模块中(在标题中),我将其构造如下:

class BaseUserError(Exception):
    pass

class AccountError(BaseUserError):
    pass

class DebitError(AccountError):
    pass

class CreitError(AccountError):
    pass

希望将它们移动到用作子类的类中(例如,Account 类、Client 类等等)。这样看来似乎更正确。谁存储在哪里以及为什么存储?

python
  • 1 个回答
  • 35 Views
Martin Hope
Даниил
Asked: 2025-04-28 17:54:13 +0000 UTC

Mixamo 已停止工作

  • 4

最近重新安装了 Windows 并发现一个问题:最近,当我尝试访问Mixamo网站时,它出现了错误。Не удается получить доступ к сайту 我使用了不同的浏览器和搜索引擎,打开/关闭了 VPN 和 Windows 内置的防病毒软件,但总是出现相同的错误,我不知道还能尝试什么。


我还尝试将网络 DNS 更改为

8.8.8.8
8.8.4.4

此外,无论是否使用 VPN,手机上的一切都能完美运行 - 一切都可以顺利加载。手机和电脑连接同一个Wi-Fi。没什么帮助

我希望你能帮忙。

我已将错误截图附加到以下位置。 歌剧

谷歌

互联网一切正常,其他网站正在加载,只有Mixamo存在问题

windows
  • 1 个回答
  • 25 Views
Martin Hope
Valerons
Asked: 2025-04-28 13:35:16 +0000 UTC

使用 Golang 发布应用程序

  • 7

我想了解如何构建用 Go 语言编写的应用程序。如果你写入命令go build,则只会编译一个可执行文件。这就是运行应用程序所需的全部内容吗?例如,在 C# 中,如果您构建一个项目,将出现一个单独的发布文件夹,其中将包含所有依赖项。已发布的 Go 应用程序的所有依赖项存储在哪里?

golang
  • 1 个回答
  • 29 Views
Martin Hope
Макс Тимашков
Asked: 2025-04-28 03:34:14 +0000 UTC

优化 C# 代码,计算对象之间的距离

  • 6

大家好。有一个代码可以找到物体之间的最小距离并选择该物体以便在游戏中进行进一步的交互。

我看到并知道代码看起来很糟糕,但我不知道如何正确缩短它(例如,使用 foreach)。

请帮助我,但不要冒犯我)

代码:

void Distanse()
{
    if (bots[0] != null)
    {
        if (players[0] != null)
        {
            float tmp1 = Vector3.Distance(players[0].transform.position, bots[0].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[0];
            }
        }

        if (players[1] != null)
        {
            float tmp1 = Vector3.Distance(players[1].transform.position, bots[0].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[0];
            }

        }

        if (players[2] != null)
        {
            float tmp1 = Vector3.Distance(players[2].transform.position, bots[0].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[0];
            }

        }



    }

    if (bots[1] != null)
    {
        if (players[0] != null)
        {
            float tmp1 = Vector3.Distance(players[0].transform.position, bots[1].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[1];
            }
        }

        if (players[1] != null)
        {
            float tmp1 = Vector3.Distance(players[1].transform.position, bots[1].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[1];
            }

        }

        if (players[2] != null)
        {
            float tmp1 = Vector3.Distance(players[2].transform.position, bots[1].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[1];
            }

        }



    }
    if (bots[2] != null)
    {
        if (players[0] != null)
        {
            float tmp1 = Vector3.Distance(players[0].transform.position, bots[2].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[2];
            }
        }

        if (players[1] != null)
        {
            float tmp1 = Vector3.Distance(players[1].transform.position, bots[2].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[2];
            }

        }

        if (players[2] != null)
        {
            float tmp1 = Vector3.Distance(players[2].transform.position, bots[2].transform.position);
            if (tmp1 < distance)
            {
                distance = tmp1;
                botNearest = bots[2];
            }

        }



    }
c#
  • 1 个回答
  • 52 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