由于CSS / HTML不在乎双精度空格,因此此HTML代码:
import requests
session = requests.session()
def stringify(obj: dict) -> dict:
"""turn every value in the dictionary to a string"""
for k,v in obj.items():
if isinstance(v,dict):
# if value is a dictionary,stringifiy recursively
stringify(v)
continue
if not isinstance(v,str):
if isinstance(v,bool):
# False/True -> false/true
obj[k] = str(v).lower()
else:
obj[k] = str(v)
return obj
with open('cookies.json') as f:
cookie_list: list = json.load(f)
# create the cookie jar from the first cookie
cookie_jar = requests.utils.cookiejar_from_dict(stringify(cookie_list[0]))
# append the rest of the cookies
for cookie in cookie_list[1:]:
requests.utils.add_dict_to_cookiejar(cookie_jar,stringify(cookie))
session.cookies = cookie_jar
...在视觉上呈现为:
<p>This is a sentence. This is another sentence.</p>
它“吞噬”任何其他空格。 (除非您使用特殊的格式设置规则,否则这些规则会将所有内容都变成严格的“纯文本”,并破坏了CSS / HTML的含义。)
出于这个原因,我假设必须有一些CSS属性来告诉浏览器段落中每个句子之间应放置多少空间(而不是每个单词,每个字母之间或仅在该段的开头),例如:
This is a sentence. This is another sentence.
如果该属性存在,那么在处理CSS的所有年份中我从未遇到过。如果不存在,则是唯一手动添加的解决方法
p
{
space-between-sentences: 2em;
}
到处强迫两个空格?因为这对我来说真是丑陋/骇人听闻/不正确...