小编Jih*_*hoi的帖子

如何设置 Markdown 表格内图像的相对大小

我想让 Markdown内的图像具有相同的大小。但是,我拥有的图像资源大小不同。因此我想在表格单元格内设置相对图像大小。

如何在不实际更改图像资源大小的情况下使其Fig 2看起来像?Fig 1

|     |     |     |     |     |
| :-: | :-: | :-: | :-: | :-: |
|     |     |     |     |     |
| 180 | 182 | 240 | 250 | 250 |
| <img src="assets/textbooks/180.jpg" width="100%"> | <img src="assets/textbooks/182.jpg" width="100%"> | <img src="assets/textbooks/240.jpg" width="100%"> | <img src="assets/textbooks/250-1.jpg" width="100%"> | <img src="assets/textbooks/250-2.jpg" width="100%"> |
Run Code Online (Sandbox Code Playgroud)

图 1. 预期

(相同的代码,但实际图像资源具有相同的大小)

在此输入图像描述

图 2. 电流输出

(我目前拥有的)

在此输入图像描述

markdown github-flavored-markdown

6
推荐指数
1
解决办法
3018
查看次数

美丽的汤选择谷歌图片返回空列表

我想使用从Google Arts & CultureBeautifulSoup检索信息。我检查了许多 stackoverflow 帖子(、、、、、 ) [1], 但 仍然无法检索到信息。[2][3][4][5]

但是,我想要每个图块(图片)的 ( li) 信息,例如 href,find_allselect one返回空列表或无。

您能帮我获取“e0WtYb HpzMff PJLMUc”类锚标记的以下 href 值吗?

href="/entity/claude-monet/m01xnj?categoryId=artist"

以下是我尝试过的。

import requests
from bs4 import BeautifulSoup

url = 'https://artsandculture.google.com/category/artist?tab=time&date=1850'
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html.parser')
print(soup.find_all('li', class_='DuHQbc'))                 # []
print(soup.find_all('a', class_='PJLMUc'))                  # []
print(soup.find_all('a', class_='e0WtYb HpzMff PJLMUc'))    # []
print(soup.select_one('#tab_time > div > div:nth-child(2) > div > ul > li:nth-child(2) > a'))  # …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup web-crawler

5
推荐指数
1
解决办法
469
查看次数

BigQuery 使用动态键和值提取嵌套 JSON

我想用动态键提取嵌套的 JSON。我目前可以借助和提取密钥,但解析 JSON 对象的值会产生意外的结果。“[对象对象]”12

使用动态键和值解析嵌套 JSON 的正确方法是什么?(我不想使用自定义 JS UDF,但我不确定现有的 JSON 函数是否可以处理该问题。)

记录的输入栏
{
    "key1":{"ItemID":1,"UseCount":4,"ItemCount":7},
    "key2":{"ItemID":2,"UseCount":5,"ItemCount":8},
    "key3":{"ItemID":3,"UseCount":6,"ItemCount":9}
    ...
}
Run Code Online (Sandbox Code Playgroud)
当前查询

bigquery-utilsjson_extract_keys() json_extract_values()

WITH
sample_logs AS (
    SELECT '{"key1":{"ItemID":1,"UseCount":4,"ItemCount":7},"key2":{"ItemID":2,"UseCount":5,"ItemCount":8},"key3":{"ItemID":3,"UseCount":6,"ItemCount":9}}' as json_string,
    UNION ALL SELECT '{"key4":{"ItemID":1,"UseCount":4,"ItemCount":7},"key5":{"ItemID":2,"UseCount":5,"ItemCount":8}}'
)
SELECT
    json_string,
    key,
    TO_JSON_STRING(value) as value,
FROM sample_logs
CROSS JOIN UNNEST(bqutil.fn.json_extract_keys(json_string)) as key WITH OFFSET
INNER JOIN UNNEST(bqutil.fn.json_extract_values(json_string)) as value WITH OFFSET USING (OFFSET)
;
Run Code Online (Sandbox Code Playgroud)
结果

在此输入图像描述

预期成绩
JSON_STRING1  |  "key1"   |  {"ItemID":1,"UseCount":4,"ItemCount":7}  -- <- not [object Object]
JSON_STRING1  | …
Run Code Online (Sandbox Code Playgroud)

google-bigquery bigquery-udf

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

Python:变量命名约定 - 文件,路径,文件路径,file_path

我想知道Python中以下变量的正确命名约定,我找不到Google Style GuidePEP8中的一个

(假设我有以下Python代码)

output_file = open(output_file_path,'w')

out文件名的最佳变量名是什么?

我相信变量名称的可能选项就像

output_file outputfile outfile out_file outfile

路径变量可以是这样的

output_file_path output_filepath output_path out_path ...

python coding-style naming-conventions

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