springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-18 13:39:57
204
作为函数参数,如何将变量放在双引号字符串中?
下面是我尝试过的将变量放入带引号的字符串中的四种经典方法。
<代码>K=";老板";test=' p:contains({})'.format(K)打印(测试,类型(测试))测试_2=“ p:包含(%s)”%(K)打印(测试,类型(测试_2))测试_3=f ' p:contains({K})'打印(测试,类型(测试_3))测试_4=' p:contains('+str(K)+')'打印(测试,类型(测试_4))
它给出了以下输出。到目前为止,一切顺利。
k = "boss"
test = 'p:contains({})'.format(k)
print(test, type(test))
test_2 = 'p:contains(%s)' % (k)
print(test, type(test_2))
test_3 = f'p:contains({k})'
print(test, type(test_3))
test_4 = 'p:contains('+str(k)+')'
print(test, type(test_4 ))
问题就在这里。我抓取了";爬虫测试网站";用于测试目的。
p:contains(boss) <class 'str'>
p:contains(boss) <class 'str'>
p:contains(boss) <class 'str'>
p:contains(boss) <class 'str'>
如果一切顺利,输出应该是这样的
<代码>";单独的桌面页面,带有单独的移动和/或amp";";将桌面页面与AMP页面分隔为AMP和移动";";使用不同的H1";分离桌面";无移动配置";
顺晟科技:
只需使用引号..
import requests
from bs4 import BeautifulSoup
url = "https://crawler-test.com/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
soup.select('div div:nth-child(2) div')
mobile_list = ["Separate Desktop page with separate mobile and/or AMP",
"Separate Desktop page with AMP page as AMP and Mobile",
"Separate Desktop with different H1",
"No mobile configuration"]
for m in mobile_list:
# This is the tricky part
# I want to put the m inside
for a in soup.select_one('a:contains(m)'):
#for a in soup.select_one('a:contains({})'.format(m)):
#for a in soup.select_one('a:contains(%s)' % m):
#for a in soup.select_one(f'a:contains({m})'):
#for a in soup.select_one('a:contains('+str(m)+')'):
print(a)
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11