파이썬에서 코드를 작성하려고합니다. 그러면 문자열 입력에서 HTML 태그가 제거됩니다. 그러나 어떤 이유로 코드는 가정용 파이썬 설치에서 실행되지 않고 Udacity 인터페이스에서 종료됩니다.Python에서 기본 검색 및 바꾸기가 실행되지 않습니다.
어디로 잘못 가고 있습니까?
def remove_tags(sentence):
list = []
state = 0
while state == 0:
location1 = sentence.find('<')
location2 = sentence.find('>',location1)
if location1 != -1:
chamber = sentence[location1:location2+1]
sentence.replace(chamber,'')
elif location1 == -1:
state = 1
return sentence.split()
return sentence.split()
print remove_tags('''<table cellpadding='3'>
<tr><td>Hello</td><td>World!</td></tr>
</table>''')
감사합니다! 문제 해결됨.;) – c3ntury