我希望所有漂亮的汤输出应该在一行中,而不是在换行符中。
HTML:
<h1 class="page-title nosp" data-price-promise-enabled="">
<span>SAMSUNG</span>
<span>QE43Q60RATXXU 43" Smart 4K Ultra HD HDR QLED TV with Bixby</span>
</h1>代码:
try:
title = soup.find('h1', attrs={'class':'page-title nosp'}).text
except:
title = None航站楼:
PS C:\Users\Zandrio> & C:/Users/Zandrio/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/Zandrio/Documents/Advanced Project/Proxy/currys.py"
SAMSUNG
QE43Q60RATXXU 43" Smart 4K Ultra HD HDR QLED TV with Bixby我希望输出没有空格或换行符
SAMSUNG QE43Q60RATXXU 43" Smart 4K Ultra HD HDR QLED TV with Bixby发布于 2020-03-14 21:41:08
试一试
print(title.strip().replace('\n',' '))https://stackoverflow.com/questions/60687338
复制相似问题