摘要: 刚开始接触 bs4 的时候,我也很迷茫,觉得 string 属性和 text 属性是一样的,不明白为什么要分成两个属性。 html = '<p>hello world</p>' soup = BeautifulSoup(html, 'lxml') p = soup.p print(p.string) 阅读全文
posted @ 2018-11-14 16:37 丹枫无迹 阅读(9250) 评论(0) 推荐(0) 编辑
摘要: S.strip(chars=None) strip 函数用于去除字符串首尾的空格,当 chars 不为 None 时,则删除字符串首尾的 chars 中的字符。 当 chars=None 时,去除首尾空格,没啥好说的,我们来看 chars 不为 None 时的情况。 str = 'abc123abc 阅读全文
posted @ 2018-11-14 14:52 丹枫无迹 阅读(1395) 评论(2) 推荐(1) 编辑