.string获取文本内容但没有索引值
.text可以获取文本内容并且有索引值
例如:
tem = day.find('span', {'class': 'tem'}).text # 找到温度
temp.append(tem[tem.index('/') + 1:-1]) # 找到最低气温
这里要用到索引的只能用.text
.string获取文本内容但没有索引值
.text可以获取文本内容并且有索引值
例如:
tem = day.find('span', {'class': 'tem'}).text # 找到温度
temp.append(tem[tem.index('/') + 1:-1]) # 找到最低气温
这里要用到索引的只能用.text