return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or bytes-like object

2020. 7. 1. 21:51python



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

re.sub 사용시 에러

 

어쩌구 저쩌구

    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

 

나온다... 치환을 하고 싶어서 사용한 re.sub()가 구글링에선 많이 보이는데 오류가 난다? 

 

tag = re.sub('<.+?>', '', tag)
(태그를 제거 하고 싶었다)

 

말고 

 

tag = re.sub('<.+?>', '', '{}'.format(tag))

 

잘 알고 있는 format을 써보자..