RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

全部问题

Martin Hope
Natali
Asked: 2024-12-07 04:16:30 +0000 UTC

如何在分区内进行排名,以便相同的值具有相同的排名。但计数器有用吗?

  • 5

有一个表“DataBase1”.Table1”,其中包含按时间间隔(Start_DT – End_DT)有关客户端(包括其服务通道)的各种信息。从此表中,您需要选择所有数据(下面的查询示例)和另一个具有递增键的计算列“Key”,每个客户端的键随着其服务渠道的每次变化而增加。任务 1 的基本请求示例:

SELECT
  CLIENT_ID, START_DT, END_DT, CHANNEL, «ваш текст» AS KEY
FROM
  "DataBase1".Table1
WHERE 1 = 1
  AND CLIENT_ID IN(123, 124)
ORDER BY
  CLIENT_ID, START_DT DESC

任务 1 的卸载示例:

CLIENT_ID START_DT END_DT 渠道 钥匙
124 18年11月17日 99年12月31日 大量的 1
124 2018年10月10日 2018年11月16日 大量的 1
123 2018年11月13日 99年12月31日 大量的 3
123 2018年12月11日 2018年12月11日 总理 2
123 2018年11月8日 2018年11月11日 大量的 1
123 2018年10月13日 2018年11月7日 大量的 1

那些。在 CLIENT_ID 分区内,您需要一个计数器来计算每个通道的变化。在这种情况下,它显示为该 SELECT 中的附加字段。

我试图使 DENSE_RANK() 成为窗口函数

SELECT CLIENT_ID, START_DT, END_DT, CHANNEL,
    DENSE_RANK() OVER (PARTITION BY client_id ORDER BY channel)
FROM table1
ORDER BY client_id DESC, start_dt DESC;

结论是:

CLIENT_ID START_DT END_DT 渠道 钥匙
124 18年11月17日 99年12月31日 大量的 1
124 2018年10月10日 2018年11月16日 大量的 1
123 2018年11月13日 99年12月31日 大量的 1
123 2018年12月11日 2018年12月11日 总理 2
123 2018年11月8日 2018年11月11日 大量的 1
123 2018年10月13日 2018年11月7日 大量的 1
postgresql
  • 1 个回答
  • 28 Views
Martin Hope
Александр
Asked: 2024-12-06 23:35:23 +0000 UTC

自动点击器同时绑定到 GUI 中的按钮和热键

  • 6

我是Python新手。我正在编写一个自动点击器,它应该响应“开始”和“停止”按钮,并使用“6”和“7”热键执行相同的功能。

from tkinter import *
import mouse
import keyboard
import time

window = Tk()
window.title('clicker')
window.wm_attributes('-topmost', True)
window.geometry('250x250')
window.resizable(False, False)


def start():
        btn_stop['state'] = 'active'
        btn_start['state'] = 'disabled'
        while btn_stop['state'] == 'active':
            mouse.click()
            window.update()
            time.sleep(0.01)


def stop():
    btn_start['state'] = 'active'
    btn_stop['state'] = 'disabled'

keyboard.add_hotkey('7', stop)
keyboard.add_hotkey('6', start)
btn_start = Button(window, text='Старт', command=start, state='active')
btn_start.place(width=70, y=120, x=90)

btn_stop = Button(window, text='Стоп', command=stop, state='disabled')
btn_stop.place(width=70, y=60, x=90)

window.mainloop()

使用按钮,程序可以正常工作,但是如果您通过热键“6”启动它,则无法使用“7”键停止它,只能通过“停止”按钮来完成。此外,如果您通过“开始”按钮启动程序,那么通过“7”键它会平静地停止。

我想(我可能是错的,因为我不知道所有的微妙之处)由于某种原因keyboard.add_hotkey它不会响应任何其他键,直到上一个命令完成(并且我在那里有一个无限循环)。

也许我错了,但我请求你的帮助。我不需要保存这个特定的代码模型,最主要的是程序以相同的方式工作并响应按键和按钮。我希望得到回应。

python
  • 1 个回答
  • 22 Views
Martin Hope
DasAuto
Asked: 2024-12-06 19:25:16 +0000 UTC

Python 简化设计

  • 5

请告诉我如何简化代码的功能。我已经整个脑袋都坏掉了。假设我有一个带有属性的类:

self.count = 0
self.dount = 0
self.mount = 0
self.kount = 0

例如,有两个函数:一个通过循环进行加法,另一个进行减法:

for key, value in dicti.items(): 
    if key == '+':
        check_pl(value)
    elif == '-':
        check_ms(value)


def check_pl(value): 
    if value == 'ons':
        self.count += 1
    if value == 'ions':
        self.dount += 1
    if value == 'sions':
        self.mount += 1
    if value == 'visions':
        self.kount += 1

def check_ms(value): 
    if value == 'ons':
        self.count -= 1
    if value == 'ions':
        self.dount -= 1
    if value == 'sions':
        self.mount -= 1
    if value == 'visions':
        self.kount -= 1

是否可以简化这个函数,这样就不会因为有两个几乎相同的函数和一堆重复的变量而出现这么长的混乱代码?

python
  • 1 个回答
  • 31 Views
Martin Hope
polymamylop
Asked: 2024-12-06 09:17:20 +0000 UTC

创建 Docker 容器时遇到的问题

  • 5

我安装了 OpenAi Universe

cd ~ git clone https://github.com/openai/universe.git
cd universe
pip install -e .

安装过程中出现这样的消息:

Obtaining file:///Users/user/universe
  Preparing metadata (setup.py) ... done
Requirement already satisfied: universe in /Users/user/universe (0.21.5)
Requirement already satisfied: autobahn>=0.16.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (24.4.2)
Requirement already satisfied: docker-py==1.10.3 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.10.3)
Requirement already satisfied: docker-pycreds==0.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.2.1)
Requirement already satisfied: fastzbarlight>=0.0.13 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.0.14)
Requirement already satisfied: go-vncdriver>=0.4.8 in /Users/danilabrikanov/go-vncdriver (from universe==0.21.5) (0.4.19)
Requirement already satisfied: gym>=0.8.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (0.26.2)
Requirement already satisfied: Pillow>=3.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (10.4.0)
Requirement already satisfied: PyYAML>=3.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (6.0.1)
Requirement already satisfied: six>=1.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (1.16.0)
Requirement already satisfied: twisted>=16.5.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (23.10.0)
Requirement already satisfied: ujson>=1.35 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from universe==0.21.5) (5.10.0)
Requirement already satisfied: requests<2.11,>=2.5.2 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (2.10.0)
Requirement already satisfied: websocket-client>=0.32.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from docker-py==1.10.3->universe==0.21.5) (1.8.0)
Requirement already satisfied: txaio>=21.2.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (23.1.1)
Requirement already satisfied: cryptography>=3.4.6 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (43.0.0)
Requirement already satisfied: hyperlink>=21.0.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (21.0.0)
Requirement already satisfied: setuptools in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from autobahn>=0.16.0->universe==0.21.5) (75.1.0)
Requirement already satisfied: numpy in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from go-vncdriver>=0.4.8->universe==0.21.5) (1.26.4)
Requirement already satisfied: cloudpickle>=1.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (3.0.0)
Requirement already satisfied: gym_notices>=0.0.4 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from gym>=0.8.1->universe==0.21.5) (0.0.8)
Requirement already satisfied: attrs>=21.3.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.1.0)
Requirement already satisfied: automat>=0.8.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (20.2.0)
Requirement already satisfied: constantly>=15.1 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (23.10.4)
Requirement already satisfied: incremental>=22.10.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (22.10.0)
Requirement already satisfied: typing-extensions>=4.2.0 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (4.11.0)
Requirement already satisfied: zope-interface>=5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from twisted>=16.5.0->universe==0.21.5) (5.4.0)
Requirement already satisfied: cffi>=1.12 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (1.17.1)
Requirement already satisfied: idna>=2.5 in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from hyperlink>=21.0.0->autobahn>=0.16.0->universe==0.21.5) (3.7)
Requirement already satisfied: pycparser in /opt/anaconda3/envs/universe2/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=3.4.6->autobahn>=0.16.0->universe==0.21.5) (2.21)
Installing collected packages: universe
  Attempting uninstall: universe
    Found existing installation: universe 0.21.5
    Uninstalling universe-0.21.5:
      Successfully uninstalled universe-0.21.5
  DEPRECATION: Legacy editable install of universe==0.21.5 from file:///Users/user/universe (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
  Running setup.py develop for universe
Successfully installed universe

接下来我需要创建一个 Docker 镜像:

docker build -t universe .

运行该命令后,创建时出现错误:

[+] Building 3.2s (10/18)                                  docker:desktop-linux
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 1.48kB                                     0.0s
 => [internal] load metadata for docker.io/library/ubuntu:16.04            3.0s
 => [auth] library/ubuntu:pull token for registry-1.docker.io              0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 66B                                           0.0s
 => [ 1/13] FROM docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801  0.0s
 => [internal] load build context                                          0.0s
 => => transferring context: 13.44kB                                       0.0s
 => CACHED [ 2/13] RUN apt-get update     && apt-get install -y libav-too  0.0s
 => CACHED [ 3/13] RUN true                                                0.0s
 => CACHED [ 4/13] RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip     && ln   0.0s
 => ERROR [ 5/13] RUN pip install gym[all]                                 0.2s
------                                                                          
 > [ 5/13] RUN pip install gym[all]:                                            
0.164 Traceback (most recent call last):                                        
0.164   File "/usr/local/bin/pip", line 7, in <module>                          
0.164     from pip._internal.cli.main import main                               
0.164   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 67
0.164     sys.stderr.write(f"ERROR: {exc}")
0.164                                    ^
0.164 SyntaxError: invalid syntax
------
Dockerfile:36
--------------------
  34 |     
  35 |     # Install gym
  36 | >>> RUN pip install gym[all]
  37 |     
  38 |     # Get the faster VNC driver
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install gym[all]" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/lzvq2rrk75dfl8bh6pc8k4wsr

我能做些什么来解决这个问题,我读了 Sudharsan Ravichandiran 的书《Python 中的深度强化学习》。因为这个问题我无法继续阅读。

Dockerfile:

FROM ubuntu:16.04

RUN apt-get update \
    && apt-get install -y libav-tools \
    python3-numpy \
    python3-scipy \
    python3-setuptools \
    python3-pip \
    libpq-dev \
    libjpeg-dev \
    curl \
    cmake \
    swig \
    python3-opengl \
    libboost-all-dev \
    libsdl2-dev \
    wget \
    unzip \
    git \
    golang \
    net-tools \
    iptables \
    libvncserver-dev \
    software-properties-common \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ARG BASE_COMMAND="true"
RUN $BASE_COMMAND

RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip \
    && ln -sf /usr/bin/python3 /usr/local/bin/python \
    && pip install -U pip

# Install gym
RUN pip install gym[all]

# Get the faster VNC driver
RUN pip install go-vncdriver>=0.4.0

# Install pytest (for running test cases)
RUN pip install pytest

# Force the container to use the go vnc driver
ENV UNIVERSE_VNCDRIVER='go'

WORKDIR /usr/local/universe/

# Cachebusting
COPY ./setup.py ./
COPY ./tox.ini ./

RUN pip install -e .

# Upload our actual code
COPY . ./

# Just in case any python cache files were carried over from the source directory, remove them
RUN py3clean .
python
  • 1 个回答
  • 30 Views
Martin Hope
KJlehnok .a5
Asked: 2024-12-06 05:01:13 +0000 UTC

拖放复制的 UI 对象

  • 5

我正在 Unity 的 2D 空间中创建我的游戏。

删除脚本(当其他对象位于其上时删除其他对象的对象)不会删除脚本创建的对象(第一次)

public class Create : MonoBehaviour, IPointerDownHandler {
    public void OnPointerDown(PointerEventData eventData) {
        CreateClone(eventData);
    }
    private IEnumerator WaitForMouseDown(DragDrop newDragDrop, PointerEventData eventData) {
        newDragDrop.OnBeginDrag(eventData);        //Calling OnBeginDrag

        while (Input.GetMouseButton(0)) {        //Looping if LMB is Down
            newDragDrop.OnDrag(eventData);

            yield return null; //Waiting the next Frame
        }

        newDragDrop.OnEndDrag(eventData);
    }

    public void InitiateDragDrop(DragDrop newDragDrop, PointerEventData eventData) {
        StartCoroutine(WaitForMouseDown(newDragDrop, eventData));
    }

    private void CreateClone(PointerEventData eventData) {
        //Create Clone like Prefab

        RectTransform rectTransform = _clone.GetComponent<RectTransform>();
        rectTransform.SetParent(_canvas.transform, false);        //Clone correct position

        //Add Component DragDrop for Clone
        DragDrop newDragDrop = _clone.AddComponent<DragDrop>();        //Add Component DragDrop for Clone
        //Get canvas for DragDrop for correct work

        InitiateDragDrop(newDragDrop, eventData);

        Destroy(_clone.GetComponent<Create>());        //Delete Script Create on the Clone
    }
}

这段代码已经被稍微清理了一下,它的任务是创建一个单击时将跟随鼠标的对象,直到您释放 LMB(使用 DragDrop 事件实现)这部分代码可以完美地运行一点,但是

public class Delete : MonoBehaviour, IDropHandler {
    public void OnDrop(PointerEventData eventData) {
        Debug.Log("Destroyed the Object");

        if (eventData.pointerDrag != null) {
            Destroy(eventData.pointerDrag); //Destroy OnDrop Object
        }
    }
}

删除脚本(也称为使用事件,也可以正常工作,为了清楚起见,在这里)

如果在创建对象时,不释放鼠标,将其拖动到删除,那么什么也不会发生,说实话,我认为整个点都在 IEnumerator (Corutina) 中,因为其他一切都可以正常工作,即使是通过连接 Debug.Log 它显示一切正常,但要删除该对象,您首先必须放开它,然后再次拾起它并在删除器上释放它

简而言之:代码创建了对象的副本,并允许在我们按住 LMB 时移动它。但由于某种原因,如果将对象拖到删除器中,则无法删除该对象(您需要再次尝试删除)

如果你在Unity中手动创建一个对象并赋予它所需的拖放属性,那么删除它不会有任何问题,即使你删除了Create脚本的删除功能,问题仍然存在

public class DragDrop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
    public void OnBeginDrag(PointerEventData eventData) {
        Debug.Log("DragDrop  |  On Being Drag");

        canvasGroup.alpha = .2f;
        canvasGroup.blocksRaycasts = false;
    }

    public void OnDrag(PointerEventData eventData) {
        rectTransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
    }

    public void OnEndDrag(PointerEventData eventData) {
        Debug.Log("DragDrop  |  On End Drag");

        canvasGroup.alpha = 1f;
        canvasGroup.blocksRaycasts = true;
    }
}
c#
  • 1 个回答
  • 35 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