Program Language/Python

(python) bad operand type for unary +: 'str'

야곰야곰+책벌레 2023. 11. 27. 11:55
728x90
반응형
news_html = ""
for i in range(len(df_news_final)) :
    news_html = news_html + "<div><p><a href ='\
    " + str(df_news_final.loc[i, '원문주소']) + "'>\
    " + str(df_news_final.loc[i, '뉴스제목']) + "</a>\
    " + str(df_news_final.loc[i, '매체']) + " \
    " + str(df_news_final.loc[i, '등록일']) + "</p></div>"

python 3에서

final_sentence="""Pulled
"""+stock+""".""" 
print (final_sentence)

이건 동작하지만, 

final_sentence="""Pulled"""
+stock+""".""" 
print (final_sentence)

는 동작하지 않는다.

아마 operator 정의 문제인 듯하다.

아래와 같이 하면 잘 된다.

 

728x90
반응형

'Program Language > Python' 카테고리의 다른 글

(python) pandas ix -> iloc  (0) 2023.11.28
(python) 네이버 뉴스 크롤링  (0) 2023.11.27
(python) 정부 입찰 공고 자료 수집  (0) 2023.11.23
(python) 셀레리움 에러  (0) 2023.11.23
(python) 국세청 사업자 조회  (0) 2023.11.23