백엔드/Python

[python] not all arguments converted during string formatting

작은소행성☄️ 2020. 9. 28. 10:21
728x90

파이썬에서 문자열 포매팅을 하는데 생긴 오류이다. 

 

not all arguments converted during string formatting

 

문자열 형식화 중에 모든 인수가 변환되지는 않는다. 

 

%s 로 변수가 들어올 자리 수와, 넣고자하는 변수의 수가 맞지 않아 발생한 에러로그로

( ) 안에 있는 변수의 개수를 맞춰서 사용해주면 된다. 

 

 

예시

# ok
cursor.execute("insert into tablename (company,title,date,link) values(%s,%s,%s,%s)",val_insert)
# error
cursor.execute("insert into tablename (company,title) values(%s,%s,%s,%s)",val_insert)
728x90
반응형