RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Violet's questions

Martin Hope
Violet
Asked: 2020-06-20 17:18:42 +0000 UTC

匹配三个列表

  • 4

有3个列表:

a = [12, 12, 12, 12, 1, 1, 1]
b = [20, 21, 22, 23, 200, 201, 202]
c = ['04-04', '05-05', '06-06', '07-07', '008-008', '009-009', '100-100']

需要一个唯一值 froma来导出一个映射 fromb等于c值的重复次数a,即:

uid=12

  • 20 04-04
  • 21 05-05
  • 22 06-06
  • 23 07-07

uid=1

  • 200 008-008
  • 201 009-009
  • 202 100-100

输出唯一值a:

    for i in range(0, len(list(set(a)))):
        print('uid=' + str(sorted(set(a), key=a.index)[i]))
    >>> uid=12
    >>> uid=1

中的重复元素数a:

for i in range(0, len(list(set(a)))):
    print(a.count(sorted(set(a), key=a.index)[i]))
>>> 4
>>> 1

匹配b和c:

x = []
for j, o in zip(b, c):
    x.append(str(j) + ':' + o)
print(x)
>>> ['20:04-04', '21:05-05', '22:06-06', '23:07-07', '200:008-008', '201:009-009', '202:100-100']

进一步昏迷,如何比较我不知道

python
  • 3 个回答
  • 10 Views
Martin Hope
Violet
Asked: 2020-06-18 02:08:28 +0000 UTC

更新两个表中的值是否相等

  • 1

有两个表:

表 A:number, inn, sum, status

表 B:inn, sum, number

需要比较两个表中的 inn 和 sum 的值是否相等(A.inn=B.inn and A.sum=B.sum)

如果我没有搞砸任何事情,那么请求将是这样的:

select A.inn, A.sum, A.number from A LEFT join B on A.inn=B.inn and A.sum=B.sum where B.number is 'not mapped'

现在我需要不断更新A.status,这就是问题所在+,因为据我了解,SQLite 不支持 UPDATE statements 中的 JOIN。B.numberA.number

如何做到这一点,有可能吗?

sql
  • 1 个回答
  • 10 Views
Martin Hope
Violet
Asked: 2020-01-26 20:12:03 +0000 UTC

如何通过ajax在同一页面上提交来自两个不同表单的数据?

  • 1

该页面有一个搜索表单,通过 ajax 处理:

<body>
<script>
    function get_data() {
        $.ajax({
            url: "/get_data",
            data: $('form').serialize(),
            type: 'POST',
            success: function(response) {
                var json = jQuery.parseJSON(response)
                $('#data').html(json.data)
                console.log(response);
            },
            error: function(error) {
                console.log(error);
            }
        });
    }
</script>
<form onsubmit="get_data();return false" action="" method="post" id="form" name="form">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text" id="basic-addon1">{{count}}</span>
                </div>
                <input type="text" class="form-control" id="name" name="name" aria-describedby="button-addon2"
                required
                oninvalid="this.setCustomValidity('Заполните это поле')" oninput="setCustomValidity('')">
                <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="submit" name="finduser" value="Validate" onclick="get_data();">
                        Поиск
                    </button>
                </div>
            </div>
        </form>
<div id="data"></div>

它工作得很好,将数据传递给我的 python 并将数据返回到页面:

        @app.route('/get_data', methods=['POST'])
        def get_data():
        if request.form['name'] == '':
           lst = search_user(request.form['name'].lower())
           return json.dumps({'data': render_template('response.html', 
           lst=lst, len=range(0, len(lst)))})

我需要添加另一个表单,我创建了

@app.route('/add_data', methods=['POST'])
def add_data():
  print(request.form['l_name'])

向页面添加了一个新表单,并复制了该功能:

<script>
    function add_data() {
        $.ajax({
            url: "/add_data",
            data: $('adduser').serialize(),
            type: 'POST',
            success: function(response) {
                console.log(response);
            },
            error: function(error) {
                console.log(error);
            }
        });
    }
</script>

    <form onsubmit="add_data();return false" action="" method="post" id="adduser" name="adduser">
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <input type="text" class="form-control" id="l_name" name="l_name" placeholder="Фамилия" required oninvalid="this.setCustomValidity('Заполните это поле')" oninput="setCustomValidity('')">
  </div>
  </div>
  </form>
  <button class="btn btn-success" type="submit" name="adduser" value="Validate" onclick="add_data();">Добавить</button>

但它没有用。我在 PyCharm 控制台中遇到错误:

print(request.form['l_name'])
raise exceptions.BadRequestKeyError(key)
KeyError: 'l_name'

如何通过 ajax 从不同形式的 python 中获取数据?

python
  • 1 个回答
  • 10 Views
Martin Hope
Violet
Asked: 2020-07-18 21:26:25 +0000 UTC

从数组中获取值[关闭]

  • -2
关闭。这个问题需要澄清或补充细节。目前不接受回复。

你想改进这个问题吗?通过编辑此帖子添加更多详细信息并澄清问题。

4年前关闭。

改进问题
Array
(
    [id] => 164770127965849081
    [app] => 54680000
    [user_id] => 
    [presence] => offline
    [presence_details] => Array
        (
            [presence] => offline
        )

    [props] => Array
        (
            [$last_seen] => 2016-07-18T10:06:39
            [$sessions] => 1
            [$longitude] => 36.00000
            [$country] => Russia
            [$score] => 26
            [$active_device_guid] => ffffffff-aaaa-4444-cccc-ec82488ff21b
            [$name_placeholder] => honey-brown-sandwich
            [$latitude] => 50.0000
            [$conversations_emails] => 2
            [$email] => 123@123.com
            [$device_type] => mobile
            [$last_contacted] => 2016-07-16T16:20:16
            [$initial_referrer] => https://yandex.ru/
            [$region] => Belgorodskaya Oblast'
            [$last_session_referrer] => https://yandex.ru/
            [$initial_referrer_domain] => yandex.ru
            [$viewed_products] => Array
                (
                    [0] => Двухфазный кондиционер №1 Q3 для сильно поврежд волос
                    [1] => Масло №2 Q3 для поврежденных волос
                    [2] => Набор для заботливой мамы
                    [3] => Сыворотка для волос Манго ESTEL MOHITO 60 мл
                    [4] => Масло-блеск №3 Q3 для всех типов волос
                )

            [$city] => Belgorod
        )

    [props_custom] => Array
        (
        )

)

需要从 [props] => Array 获取 [$email]

php
  • 1 个回答
  • 10 Views
Martin Hope
Violet
Asked: 2020-02-03 21:26:52 +0000 UTC

当“a”包含两个不同的值时处理事件

  • 2
shiftlist = {'fn': key, 'begin': begintime, 'end': endtime}
    ag = requests.get(URlshiftlist, headers=ST, params=shiftlist)
    string = json.loads(ag.text)
    title = string['records']
    a = [item['closeDateTime'] for item in title]
    print(a)

并且可能包含:

a = [2018-02-03T15:02:57]

a = [None]

a = []

    if a:
        URL = tlgrm
        msg = {'chat_id': 0000, 'text': '✅ ' + value + ' | Bla'}
        r = requests.post(URL, data=msg)

    if not a:
        URL = tlgrm
        msg = {'chat_id': 0000, 'text': 'ℹ️ ' + value + ' | Bla bla'}
        r = requests.post(URL, data=msg)

if a: 当 a = [2018-02-03T15:02:57] 和 a = [None] 时作出反应

如何使 if a:仅在 a = [2018-02-03T15:02:57] 时做出反应?

python
  • 2 个回答
  • 10 Views
Martin Hope
Violet
Asked: 2020-01-17 17:19:34 +0000 UTC

保存用户发送给机器人的图像

  • 2

需要保存用户发送给机器人的图像。据我了解,您需要获取 file_id 并使用 getFile,但我无法弄清楚(

你能告诉我如何实施吗?

最近熟悉的pyTelegramBotAPI

telegram-bot
  • 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