python_06

2021. 1. 28. 20:44python

# 1.2.10 문자열 관련함수 count(문자개수세기) find(위치 알려주기) index(위치알려주기) join(문자열 삽입) upper lower(소문자를 대문자로 대문자를 소문자로)

# lstrip rstrip strip 순서대로 왼쪽 공백 지우기 오른쪽 공백지우기 양쪽 공백 지우기

a= 'hobby'

print(a.count('b'))

 

a = "python is best choice"

print(a.find('b'))

print(a.index('y'))

 

print(",".join('abcde'))

 

a,b = "hi" ,"HI"

print(a.upper())

print(b.lower())

 

c ="\tsimple is best"

print(c)

print(c.lstrip())

 

#문자열 바꾸기(replace)

example = "python is the best"

print(example.replace("python","skinfosec"))

print(example)

 

#문자열 나누기

example = "python is the simple"

example2 = "a:b:c:d:e"

print(example.split())

print(example2.split())

'python' 카테고리의 다른 글

python_08  (0) 2021.01.28
python_07  (0) 2021.01.28
python_05  (0) 2021.01.28
python_04  (0) 2021.01.28
python_03  (0) 2021.01.27