我明白如何摆脱某些文本,但是当涉及到数字时,它会与其中的其他数字发生冲突。删除某些数字python
def get_team_odds(soup):
for i in soup:
soup_output = (i.get_text())
bleach_characters = soup_output.lstrip("Value")
return(bleach_characters.replace("for",""))
如果我使用replace
或strip
这给出了0.57 10 0
我需要摆脱10的输出和0。然而。它也从第一个中删除了一些数字。所以如果输出是10.07,它会给我.7,因为它摆脱了所有的10和0。如何根据职位或其他方式摆脱某些数字。
谢谢,我用过:words = new_chars.split('') return words [0]。完美工作 –
很高兴我能帮上忙。如果你的问题得到解答,请投票给我的回复。 –