The default is formatter="minimal". Strings will only be processed enough to ensure that Beautiful Soup generates valid HTML/XML
If you pass in formatter="html", Beautiful Soup will convert Unicode characters to HTML entities whenever possible
If you pass in formatter=None, Beautiful Soup will not modify strings at all on output. This is the fastest option, but it may lead to Beautiful Soup generating invalid HTML/XML
Finally, if you pass in a function for formatter, Beautiful Soup will call that function once for every string and attribute value in the document. You can do whatever you want in this function.
至於要找 code:
In [1]: import bs4
In [2]: bs4.BeautifulSoup.prettify.__code__
Out[2]: <code object prettify at 0x103f7f5d0, file "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/element.py", line 1198>
在官方的 doc 裡面就有完整的說明了:
Output formatters
The default is formatter="minimal". Strings will only be processed enough to ensure that Beautiful Soup generates valid HTML/XML
If you pass in formatter="html", Beautiful Soup will convert Unicode characters to HTML entities whenever possible
If you pass in formatter=None, Beautiful Soup will not modify strings at all on output. This is the fastest option, but it may lead to Beautiful Soup generating invalid HTML/XML
Finally, if you pass in a function for formatter, Beautiful Soup will call that function once for every string and attribute value in the document. You can do whatever you want in this function.
至於要找 code:
我回答過的問題: Python-QA
看代码...
可以见 https://imgur.com/gallery/VkNUv
不知道怎么显示不出来这个图片