单独执行:【未经过print输出!】. soup.prettify(): 就是多带了个换行符号! 代码: import requests from bs4 import BeautifulSoup r = requests.get(https://python123.io/ws/demo.html) demo = r.text soup = BeautifulSoup(demo, html.parser) print(soup.prettify()) print('\n') print(type(soup.prettify())) print('\n') print(str(sou