티스토리 뷰

공부

[Python] search keyword

승가비 2021. 2. 9. 01:30
728x90
st1 = "Hello World!"
st2 = "World"
idx = st1.find(st2)
if idx == -1:
    print('not exist')
else:
    print('exist at idx', idx)

https://hashcode.co.kr/questions/286/%EC%8A%A4%ED%8A%B8%EB%A7%81%EC%97%90-%ED%8A%B9%EC%A0%95-%EB%8B%A8%EC%96%B4-%EC%9C%84%EC%B9%98-%EC%B0%BE%EA%B8%B0

 

스트링에 특정 단어 위치 찾기

java의 contains나 indexOf같은 메소드가 있을까요? 이렇게 쓰려구요. if not somestring.contains("찾고 싶은 문자열"): continue

hashcode.co.kr

 

728x90
댓글