일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 코딩 테스트
- boto3
- timestamp
- Airflow
- PIP
- ds_store
- reverse v.s. reversed
- selenium-wire
- sort(reverse=True) v.s. reverse
- CI/CD
- pandas
- [초급(예비) 개발자 오픈소스 실무 역량강화 교육]
- 순수함수
- functools.wraps
- 고차함수
- 생각
- os.path
- slicing [::-1]
- OS
- 함수형 프로그래밍
- Python
- decorator
- blinker
- r-string
- sort v.s. sorted
- S3
- 쿼리
Archives
- Today
- Total
공부일지
[Python]TypeError: expected string or bytes-like object, got 'NoneType' 본문
Computer/Trouble Shooting
[Python]TypeError: expected string or bytes-like object, got 'NoneType'
이르리의 공부일지 2023. 9. 13. 15:38찾아보니 정규 표현식 쓸 때 자주 발생하는 오류라 한다.
정규 표현식은 str 타입에 적용되는데 그게 아닐 경우에 발생하는 문제이므로
str로 변환해주면 된다. (해결 방법: 함수 str() 적용)
참고 블로그
https://nyoungsom.tistory.com/62
[Python, 에러] TypeError: expected string or bytes-like object
import re def clean(x): x = re.sub("\&\w*\;", "",str(x)) df['contents'].apply(lambda x: clean(x)) 정규표현식을 사용해서 문자 제거 도중 타입에러(TypeError) 발생 ! 변경 전 re.sub("\&\w*\;", "",x) 변경 후 re.sub("\&\w*\;", "",str(x
nyoungsom.tistory.com
그런데 나의 경우 이 문제가 아니었다.
해당 오류 메시지 전문을 살펴봤을 때 크롤러 내 특정 키워드(예시. if re.findall(“\(School\)”, “”, a)에서 ‘School’와 같은)
가 있길래 그 단어를 기준으로 찾아봤다.
그런데 그 키워드를 갖는 어떤 코드문장 끝에 조용히 오타가 끼어있었다.
코드를 돌아보다가 모르는 새에 눌린 알파벳인 것 같다.
'Computer > Trouble Shooting' 카테고리의 다른 글
[Python] 버전 충돌 해결을 위해 pip 패키지 전체 삭제하는 법 (1) | 2024.09.20 |
---|---|
[Python]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (0) | 2023.09.13 |
[Mac]Bash: /경로/경로/ : is a directory 에러 (0) | 2023.09.12 |
TypeError: '<' not supported between instances of 'float' and 'str' (0) | 2023.09.11 |
[MariaDB]CSV파일 임포트 시 한글깨짐 해결 (0) | 2023.08.21 |