Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- ruby
- AWS
- laravel
- Wordpress
- working directory
- javascript
- staging area
- vue
- dockerfile
- docker
- MySQL
- imagemagick
- Ruby On Rails
- pagination
- react
- SQL
- codeigniter4
- Selenium
- linux
- Git
- ec2
- docker-compose
- controller
- props
- NGINX
- cron
- Python
- ubuntu
- php
- centOS7
Archives
- Today
- Total
내가 한 노력들
2020-10-30 python string 변수안에 특정 문자열 찾기 본문
1. 특정 문자열이 포함되어 있는지 확인할때
string = 'test test test'
if 'test in string:
print string
2. 특정 문자열이 포함된 위치를 확인할 때
string = "this is test string"
print string.find("test")
3. 특정 문자열이 여러번 포함된 경우
import re
st = [m.start() for m in re.finditer('test', 'test test test test')]
print st
출처: https://metagenomics.tistory.com/entry/여러번-찾기 [메타지노믹스]
'IT 공부 > python' 카테고리의 다른 글
[ Python ] dictionary values값으로 key값 찾기 (0) | 2020.11.08 |
---|---|
2020-11-04 python enumerate() and for문 + if 문 (0) | 2020.11.04 |
2020-10-12 Python 과 Ruby Package Manager (0) | 2020.10.12 |
2020-10-12 Python 과 Ruby 믹스인 (0) | 2020.10.12 |
2020-10-11 Python 과 Ruby 다중상속 (0) | 2020.10.11 |