小编Kus*_*ikh的帖子

flask - 显示从python到html的数据库

我有这样的代码从数据库中检索数据,我想在html中显示它.

这是app.py

@app.route('/news')
def news():
    import pymysql
    import re

    host='localhost'
    user = 'root'
    password = ''
    db = 'skripsi'

    try:
        con = pymysql.connect(host=host,user=user,password=password,db=db, use_unicode=True, charset='utf8')
        print('+=========================+')
        print('|  CONNECTED TO DATABASE  |')
        print('+=========================+')
     except Exception as e:
        sys.exit('error',e)

     cur = con.cursor()
     cur.execute("SELECT * FROM dataset")
     data = cur.fetchall()

     for row in data:
         id_berita = row[0]
         judul = row[1]
         isi = row[2]
         print('===============================================')
         print('BERITA KE', id_berita)
         print('Judul :', judul)
         print('Isi   :', isi)
         print('===============================================')

return render_template('home.html')
Run Code Online (Sandbox Code Playgroud)

这是结果

在此输入图像描述

这是berita.html.我想在div class = …

html python flask web server

7
推荐指数
2
解决办法
3万
查看次数

将Google Vision API响应转换为JSON

任务

  • 将Google Vision API响应转换为JSON

问题

  • API调用的返回值不是JSON格式

Python函数

def detect_logos(path):
"""Detects logos in the file."""
client = vision.ImageAnnotatorClient()

# [START migration_logo_detection]
with io.open(path, 'rb') as image_file:
    content = image_file.read()

image = types.Image(content=content)

response = client.logo_detection(image=image)
logos = response.logo_annotations

print('Logos:')
print(logos)
print(type(logos))
Run Code Online (Sandbox Code Playgroud)

Google在线JSON

"logoAnnotations": [
{
  "mid": "/m/02wwnh",
  "description": "Maxwell House",
  "score": 0.41142157,
  "boundingPoly": {
    "vertices": [
      {
        "x": 74,
        "y": 129
      },
      {
        "x": 161,
        "y": 129
      },
      {
        "x": 161,
        "y": 180
      },
      {
        "x": 74,
        "y": 180 …
Run Code Online (Sandbox Code Playgroud)

python json google-api

5
推荐指数
3
解决办法
1705
查看次数

我无法在Windows 7上安装python线程库

我已经使用"pip install'library name'"命令在我的计算机和其他库上成功安装了pip.我得到了我的项目所需的所有库,除了"线程"!我在网上找不到任何关于它的东西,并且问其他人没有人可以提供帮助.任何帮助都很感激.我有Python 2.7.9版本.

这是我得到的错误

在此输入图像描述

python multithreading python-2.7

4
推荐指数
1
解决办法
2万
查看次数

Stripe - 在创建结帐会话和付款时/之后将元数据添加到连接/目标帐户中

我正在做一个简单的任务。代码已经可以运行了。以下是步骤:

使用这篇文章: https: //stripe.com/docs/checkout/integration-builder

  1. 从 UI 购买门票

  2. 在后端创建结帐会话并传递所需的数据。这些都工作正常。

         const session = await this._stripe.checkout.sessions.create({
           payment_method_types: ['card'],
           customer_email: email,
           line_items: [
              {
                  price_data: {
                  currency: ###,
                  unit_amount_decimal: ###,
                  product_data: {
                       name: ###,
                       description: ###
                  }    
              },
              quantity: 1
            }
         ],
         payment_intent_data: {
             on_behalf_of: ###,
             transfer_data: {
                 destination: ###,
                 amount: ###
         },
         metadata,
         statement_descriptor: ###
      },
      mode: 'payment',
      success_url: successUrl,
      cancel_url: cancelUrl
    });
    
    Run Code Online (Sandbox Code Playgroud)

代码工作正常,我能够完成付款,并且它会通过元数据和其他字段反映到我的主帐户中。

问题:我希望将相同的元数据存入我正在转账的连接帐户中,以便我们可以共享相同的元数据。连接/目标帐户内有一个关于付款的元数据部分。这就是我想添加这些细节的地方。还有什么我需要更新的,比如收费或转账之类的?我尝试更新传输,但它们都没有将元数据反映到目标帐户中。

我应该在哪里添加哪些参数才能将元数据添加到我的连接帐户中?任何帮助都会很棒。谢谢

javascript payment-gateway stripe-payments

3
推荐指数
1
解决办法
1193
查看次数